Xml exception while saving a workbook

Exception while saving a workbook. Please note method name in the call stack. Also look at the attached image


System.Xml.XmlException: An error occurred while parsing EntityName. Line 1, position 6.
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseEntityName()
at System.Xml.XmlTextReaderImpl.ParseEntityReference()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.ParsePartialContent(XmlNode parentNode, String innerxmltext, XmlNodeType nt)
at System.Xml.XmlLoader.LoadInnerXmlElement(XmlElement node, String innerxmltext)
at ”..(XmlElement , Font , String )
at ”..(XmlElement , Shape )
at ”..(Shape )
at ”..ž()
at ”..Write(ž” , String )
at ”..e†( )
at ”..†( )
at ”..†()
at ”..Write()
at Aspose.Cells.Workbook.Save(Stream stream, SaveOptions saveOptions)

Hi,

Thanks for your posting and using Aspose.Cells for .NET

Please download and use the latest version:
Aspose.Cells
for .NET v7.3.1.1
and let us know your feedback.

If you still get the exception, please provide us your sample code and source xls/xlsx file replicating this issue, we will look into it and help you asap.

Hi Shakeel


It did not help. Same exception is thrown when saving workbook.

Regards
Ranko

Hi,

Thanks for your input.

Please provide us your source xls/xlsx file which is causing this exception.

We will look into this issue and log it in our database so that it could be fixed.

Workbook wb = new Workbook();
wb.Worksheets.Clear();
int i = wb.Worksheets.Add();
var ws = wb.Worksheets[i];
ws.Name = "New";

var index = ws.CheckBoxes.Add(10, 2, 20, ws.Cells.GetColumnWidthPixel(1) + ws.Cells.GetColumnWidthPixel(3) - 5);

Aspose.Cells.Drawing.CheckBox cb = ws.CheckBoxes[index];
cb.Text = "Location 1 ([%¤#!#%&!§§!#¤HELLO)";
cb.Font.Size = 10;
cb.TextVerticalAlignment = TextAlignmentType.Center;
var hideCell = "B" + (10 + 1).ToString();
ws.Cells[hideCell].PutValue("LnkCell");
cb.LinkedCell = hideCell;
cb.Value = true;
cb.LineFormat.ForeColor = Color.Orange;
cb.LineFormat.Style = Aspose.Cells.Drawing.MsoLineStyle.Single;
cb.LineFormat.Weight = 2;

wb.Save(@"Result.xlsx", SaveFormat.Xlsx);

And



Workbook wb = new Workbook();
wb.Worksheets.Clear();
int i = wb.Worksheets.Add();
var ws = wb.Worksheets[i];
ws.Name = “New”;

var index = ws.CheckBoxes.Add(10, 2, 20, ws.Cells.GetColumnWidthPixel(1) + ws.Cells.GetColumnWidthPixel(3) - 5);

Aspose.Cells.Drawing.CheckBox cb = ws.CheckBoxes[index];
cb.Text = “(HELLO)”;
cb.Font.Size = 10;
cb.TextVerticalAlignment = TextAlignmentType.Center;
var hideCell = “B” + (10 + 1).ToString();
ws.Cells[hideCell].PutValue(“LnkCell”);
cb.LinkedCell = hideCell;
cb.Value = true;
cb.LineFormat.ForeColor = Color.Orange;
cb.LineFormat.Style = Aspose.Cells.Drawing.MsoLineStyle.Single;
cb.LineFormat.Weight = 2;

wb.Save(@“Result.xlsx”, SaveFormat.Xlsx);

Hi,

Thanks for your sample code.

I have looked into this issue and found that the error/exception occurs because of the following commented line. It seems like you are trying to add some invalid characters i.e cb.Text

Please see the following sample code, it works fine. I have added some other valid text now. I have attached the output xlsx file also.

Please also see the screenshot for your reference.

C#

Workbook wb = new Workbook();

wb.Worksheets.Clear();

int i = wb.Worksheets.Add();

var ws = wb.Worksheets[i];

ws.Name = “New”;


var index = ws.CheckBoxes.Add(10, 2, 20, ws.Cells.GetColumnWidthPixel(1) + ws.Cells.GetColumnWidthPixel(3) - 5);


Aspose.Cells.Drawing.CheckBox cb = ws.CheckBoxes[index];

//cb.Text = “Location 1 ([%¤#!#%&!§§!#¤HELLO)”;

cb.Text = “Some other text”;

cb.Font.Size = 10;

cb.TextVerticalAlignment = TextAlignmentType.Center;

var hideCell = “B” + (10 + 1).ToString();

ws.Cells[hideCell].PutValue(“LnkCell”);

cb.LinkedCell = hideCell;

cb.Value = true;

cb.LineFormat.ForeColor = Color.Orange;

cb.LineFormat.Style = Aspose.Cells.Drawing.MsoLineStyle.Single;

cb.LineFormat.Weight = 2;


wb.Save(@“Result.xlsx”, SaveFormat.Xlsx);

Screenshot

[%¤##%&§§# are not allowed values?

Hi,

Thanks for using Aspose.Cells.

I think, you are right, these characters should be allowed as a checkbox text.

We have logged this issue in our database. We will look into this issue and fix the problem.

Once the issue is fixed or we have some other update for you, we will let you know asap.

This issue has been logged CELLSNET-41024.

Hi,

Thanks for using Aspose.Cells for .NET.

We have fixed this issue.

Please download and try the latest fix:
Aspose.Cells
for .NET v7.3.1.2

and let us know your feedback.

I have attached the output xlsx file generated by the latest fix and the screenshot for your reference.

Screenshot:

The issues you have found earlier (filed as CELLSNET-41024) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.