I try to convert some .xls file in .xlsx but for some reasons some files need to be converted from .xls to .xml and THEN .xml to .xlsx. However I have an error in the catch "Invalid syntax for a decimal numeric entity reference" that I am unable to resolve.
My best guess is this is something to do with some characters that 'Spire.xls' can't understand.
BTW I'm using spire.xls
- Code: Select all
if (dossiersBD != null && dossiersBD.ChEtat == 1)
//if (dossiersBD != null)
{
ft.CopyTo(directorypath, true);
if (System.IO.Path.GetExtension(Convert.ToString(f.FullName)) == ".xls")
{
string pathNewFile = System.IO.Path.ChangeExtension(f.FullName, ".xlsx");
Workbook workbook = new Workbook();
//workbook.Version = ExcelVersion.Version2007;
try
{
workbook.LoadFromFile(ft.FullName);
}
catch
{
string pathNewFileExtension = System.IO.Path.ChangeExtension(pathNewFile, ".xml");
System.IO.File.Move(f.FullName, pathNewFileExtension);
//using (FileStream fileStream = File.OpenRead(pathNewFileExtension))
//{
// workbook.LoadFromXml(fileStream);
//}
workbook.LoadFromXml(pathNewFileExtension);
workbook.SaveToFile(pathNewFile, ExcelVersion.Version2010);
ft = new FileInfo(pathNewFile);
}
}
Any idea why i'm getting this error message?