The award-winning singer is in a legal battle with grime artist Sami Chokri, who performs as Sami Switch, and music producer Ross O'Donoghue, who argue "Shape of You" infringes "particular lines and phrases" from their 2015 song "Oh Why".
Questioned by their lawyer Andrew Sutcliffe at the High Court in London, Sheeran, 31, said he had not been aware of Switch at the time he is accused of ripping off parts of "Oh Why", and had never heard the song before the court case.
"I have already built a long and very successful career writing original songs for both myself and a wide range of other leading artists," Sheeran said in his witness statement. "I would not have been able to do that if I was in the habit of plagiarising other writers."
Sutcliffe said Sheeran must have known of the grime artist, who he said had tweeted him directly and they had both appeared on SBTV, the British online music platform which helped launch Sheeran's career.
The lawyer said Sheeran shouted out Switch's name at Reading Festival in 2011 after being asked to by his best friend Jamal Edwards, the late founder of SBTV.
"This isn't stuff that's true," Sheeran told the High Court in London on the second day of the trial which began on Friday.
Chokri and O'Donoghue say the "Oh I" hook in "Shape Of You" is "strikingly similar" to the "Oh Why" hook in their song and that it was "extremely likely" Sheeran had previously heard their track.
Sheeran and his co-writers have denied this.
Sutcliffe, who at Friday's opening called Sheeran "a magpie", questioned the chart-topper intensively over his songwriting style and whether it was spontaneous or the result of development over time, with the influence of other artists.
The lawyer said there was overwhelming evidence at the time of writing "Shape of You" that Sheeran was collecting ideas before writing songs.
"You alter words and music which belong to others just enough to think they will pass as original," Sutcliffe said to him.
Sheeran who answered the questions confidently although sometimes appeared irked by them, rejected that assertion. He described his songs as 'excitement bottles' in his statement and said he wrote them in two hours and recently composed 25 songs in a week.
Sheeran was also asked about his decision to settle a claim over his 2015 song "Photograph" which two musicians said had the same composition as their song “Amazing”.
Sheeran agreed to hand over 35% of the publishing revenues, recognised the musicians as co-writers, and paid more than $5 million to them. Asked why he had done this rather than go to trial over what he described as a "nuisance", Sheeran said: "I took the advice of my lawyers."
Released from Sheeran's third studio album "÷", "Shape of You" stormed charts around the world upon its release in January 2017, becoming the best performing song in the United States that year.