We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pb to save xls file to xlsm with Names remove

Hello,

I would like to transform a xls file to xlsm, and remove all named ranged in all sheets.
I wrote a source code like this

using (Workbook wb = new Workbook(filenameXls))
{
WriteLog(string.Format(""{0}" open for update", filenameXls));
RemoveNamedRanges(wb);
wb.Save(newFilenameXlsm, SaveFormat.Xlsm);
WriteLog(string.Format(""{0}" save to “{1}”", filenameXls, newFilenameXlsm));
}

private void RemoveNamedRanges(Workbook wk)
{
List toRemove = new List();
foreach (var item in wk.Worksheets.Names)
{
toRemove.Add(item.FullText);
}
foreach (var item in toRemove)
wk.Worksheets.Names.Remove(item);
wk.RemoveUnusedStyles();
}

But when i try to open the new xlsm file, I have a message that tell me the files is corrupted.

Is there any solution ?

Hi Jean,


Thank you for sharing the samples.

I have evaluated the presented scenario while using the latest version of Aspose.Cells for .NET 17.1.10 and following piece of code. I am able to notice the said problem, that is; resultant XLSM becomes corrupted and cannot be loaded in Excel without repair. In order to further investigate the matter, I have raised this incident as CELLSNET-45118 in our bug tracking system. Please spare us little time to properly analyze the case and revert back with updates in this regard.

C#

var book = new Workbook(dir + “W010±+Liasse+Locale+99-02_287.xls”);
var names = book.Worksheets.Names;
for (int i = 0; i < names.Count; i++)
{
names.RemoveAt(i);
}
book.RemoveUnusedStyles();
book.Save(dir + “output.xlsm”, SaveFormat.Xlsm);

Hi again,


Adding more to my previous response, I have also noticed that simply re-saving the provided XLS to XLSM causes the same problem. I have already notified the concerned member of the product team about this discovery.

C#

var book = new Workbook(dir + “W010±+Liasse+Locale+99-02_287.xls”);
book.Save(dir + “output-simple.xlsm”, SaveFormat.Xlsm);

Hi again,


This is to update you that the ticket logged earlier as CELLSNET-45118 has been marked resolved. We will shortly share the fix here for your testing.
Hi,

Could you try our latest version/fix: Aspose.Cells for .NET v17.01.12 (attached), please any of the fixes for your underlying .NET framework version:

Aspose.Cells for .NET v17.01.12 (.NET 2.0) compiled in .NET Framework 2.0.
Aspose.Cells for .NET v17.01.12 (.NET 4.0) compiled in .NET Framework 4.0.

Your issue "CELLSNET-45118" should be fixed in it.

Let us know your feedback.

Thank you.

The issues you have found earlier (filed as CELLSNET-45118) have been fixed in Aspose.Cells for .NET 17.2.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.