So basically I have an spreadsheetwriter class which has WriteToStream() method which takes an spreadsheet as input and convert that spreadsheet to stream. Now what I am trying to do is to convert the stream into xml format so that at unit testing I am able to compare it. But I have tried many thing but always it shows the following error. System.Xml.XmlException: 'Data at the root level is invalid. Line 1, position 1.'
Stream stream = SpreadsheetWriter.WriteToStream(sheet);
stream.Seek(0, SeekOrigin.Begin);
XmlDocument xmlDocument = new();
xmlDocument.Load(stream);
xmlDocument.Save(@"..\Demo.xml");