Invalid Characters at the end in full version of Aspose

Hi,


Our company has purchased Aspose.Cells.

When I have a report which is lesser than or equal to two lines, and i try to convert the report into SpreadSheetML, i get some invalid characters at the end. [CODE: Tag for future reference]


But when i run the same report using the trail version of Aspose, I don’t get any errors. [SAMPLE: Tag for future reference]

Steps:
1. I have backed up my resultant DataTable in my code into an XML file as attached.
2. I assign this DataTable into Spread Sheet Gear Workbook
3. I call the GetStream method which converts the stream of the SSGWorkbook into XML

CODE:
DataTable dt = convertedCellSet.Table;
ssgTemplate.SetCellValue(1, 1, maxRows, maxCols, dt, “Report”);
ssgTemplate.AutoAdjustWidth(new string[] { “Report” });
ssgTemplate.Width(“A”, 35, “Report”);
:::::::::::
XmlDocument dom = new XmlDocument();
MemoryStream stream = template.GetStream(ExcelFileFormat.SpreadsheetML);
StreamReader reader = new StreamReader(stream, false);
reader.BaseStream.Position = 0;
dom = new XmlDocument();
dom.LoadXml(reader.ReadToEnd());


SAMPLE:
DataTable dt = new DataTable();
dt.ReadXml(@“D:\DevApps\Development\FinancialReport\Bin\a.txt”);
ssgWorkbook.Worksheets[sheetName].Range[0, 0, dt.Rows.Count - 1, dt.Columns.Count - 1].CopyFromDataTable(dt, SpreadsheetGear.Data.SetDataFlags.NoColumnHeaders);
::::::::::::
XmlDocument dom = new XmlDocument();
MemoryStream stream = template.GetStream(ExcelFileFormat.SpreadsheetML);
StreamReader reader = new StreamReader(stream, false);
reader.BaseStream.Position = 0;
dom = new XmlDocument();
dom.LoadXml(reader.ReadToEnd());


GETSTREAM code:
Stream stream = workbook.SaveToStream(FileFormat.OpenXMLWorkbook);
Aspose.Cells.Workbook wBook = new Aspose.Cells.Workbook(stream);
if (fileFormat == ExcelFileFormat.SpreadsheetML)
{
wBook.Save(stream, Aspose.Cells.SaveFormat.SpreadsheetML);
}
else if (fileFormat == ExcelFileFormat.HTML)
{
wBook.Save(stream, Aspose.Cells.SaveFormat.Html);
}


The funny thing is, in my CODE output, the HTML output seem to work perfectly fine!!!

I have attached the files in the following order:
1. Data Table output
2. CODE output -> Xml, HTML
3. SAMPLE output -> Xml

Please see the zip file. I am unable to remove a couple of additional attachments using the “Remove” button… Any more bugs in Page??? :slight_smile:

Please do let me know if you need any more information…

Thanks & Regards,
Anil



Hi,

Thanks for your files and reporting the problem.

Please provide me simple running C# project without the dependency of Spreadsheet Gear. Please replicate the bug with some hardcoded values or if you want to use a data table then use it in the same way as you have provided me now i.e inside xml.

Please also use the latest version: Aspose.Cells
for .NET v6.0.0.5


Thank you for helping us in sorting out this issue.

Hi,


Thanks for the response.

What I am trying to iterate is, for the same data when I comment the following two lines in my code:
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(ResourceHelper.GetLicenseStream());

It works fine. The output generated after commenting is as attached:

But when I enable them, my resultant Xml file contains a few special characters at the bottom of the file as indicated earlier…

I am a bit occupied for today if you are looking for the sample app. If you really want it will try to create one later in the night or tomorrow and pass it on…

Thanks for your assistance…

Regards,
Anil


Hi,

I created a test.xml using the CODEXmlOutput.txt after removing the invalid character manually and then after loading it again inside the workbook and saving it back, I found invalid character was not generated at the end.

Also, I tested your f3d4a1dd-057d-44b3-8689-9fec05734a7a.xml
with the same code below and it was also generated fine without any illegal character.

Please see the code below and see the input and output xml files.

I have used the latest version: Aspose.Cells
for .NET v6.0.0.5


C#


//Set the license
string licPath = @“F:\Shak-Data-R\Aspose\License\Aspose.Total.lic”;
Aspose.Cells.License lic = new Aspose.Cells.License();
lic.SetLicense(licPath);


//Open the SpreadsheetML and save it back to see if there is invalid character at the end
//string path = @“C:\Documents and Settings\Home\Desktop\f3d4a1dd-057d-44b3-8689-9fec05734a7a.xml”;
string path = @“C:\Documents and Settings\Home\Desktop\test.xml”;
Workbook workbook = new Workbook(path);

workbook.Save(path + “.out.xml”, SaveFormat.SpreadsheetML);