Free Support Forum - aspose.com

Apsose.Cell saves workbook without macros?

hello,

i am opening a workbook with macros, editing it and saving it in a different folder.
but when i opened the saved excel file the macros are not in it, they are removed so my macros are not executed
i am opening the file as
FileStream fs = File.Open(@“sablon.xls”, FileMode.Open);
workbook = new Workbook(fs);

and after the changes save it like

workbook.Save(saveFileDialog1.FileName, new XlsSaveOptions(SaveFormat.Excel97To2003));

i look workbook.HasMacros property but it says true however i cannot see the macros in saved file
any help?

Hi,

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

Please download and use the latest version:

Aspose.Cells for .NET 7.3.1

and let us know your feedback. Your problem should be resolved with the latest version.

If the problem still occurs, please provide us your source xls file which you are loading and saving using Aspose.Cells for .NET.

We will look into this issue and help you asap. In case, it is a bug, we will log it in our database so that it could be fixed asap.

i am only opening sablon.xls and saving it as test.xls but macros are removed
i am using the version 7.3.1 and ASP.NET framework is 2.0

LoadOptions lo = new LoadOptions(LoadFormat.Excel97To2003);
workbook = new Workbook(@"sablon.xls",lo);
workbook.Save(@"test.xls");

i attachted the sablon.xls excel file

Hi,

Thanks for your source file.

I was unable to replicate this issue using the latest version and everything is working fine.

Please see the code below and the output xls file generated by it. Macros are intact.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\sablon.xls”;


//First copy ole object from source workbook into destination workbook

Workbook workbook = new Workbook(filePath);


//Add something in some cell

Worksheet worksheet = workbook.Worksheets[0];


worksheet.Cells[“A1”].PutValue(“Test Aspose”);


//Save the workbook

workbook.Save(filePath + “.out.xls”);

i am copying your code, doing the samething but my sablon.xls.out.xls file is running without macros

which version are you using?
i am using aspose.cells 7.3.1.0 and the dll in the bin\net2.0\Aspose.Cells.dll

Hi,

Thanks for your feedback.

You are using the correct dll.

Please attach your output file, save it with different name like sablon.xls.out2.xls and attach here, I will check it at my end.

Please also download and see the output file generated by me at your end and let me know your feedback. Is it working fine at your end?

Also let us know, are you using .NET framework client profile on your system or it is a regular .NET framework.

Please share your complete System Environment (i.e OS, 32/64 bit, .NET framework etc)

Hi,


I have also tested your case and found the macros are there (in Ms Excel, click View|Macros|View Macros… all the macros are there) in the output (as Shakeel Faiz mentioned) file: http://www.aspose.com/community/forums/407137/postattachment.aspx

Moreover, we do not touch macros in the template file, if they are running when the workbook is opened in Ms Excel, they will be retained as they are in the output file. Also, we do not support to run macros manually via APIs. We are using v7.3.1, please make sure that you are using this version. Also give us your output file by running the code shared by Shakeel Faiz, we will check it.

Thank you.

Thanks for your help,

I am attaching the output excel file

i am using windows 7 Enterprise Service Pack 1
64-bit operating system

using a regular framework and my project is configured for target .Net Framework 2.0

your output file runs correctly in my end, View Macros and they are there but in my output theye are not in the output

Hi,

Thanks for your feedback

When I open your file, I found, it gets repaired and macros are lost.

We have logged your issue for investigation. We will look into this issue and resolve the issue or advise you.

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

This issue has been logged as CELLSNET-40995.

Hi,

We could not find any issue here.

After checking the data of sablon.xls.out2.xls , we do not think it’s saved with sablon.xls (attached in the previous post).

If you still has problem, please create a sample project with the template file and post it here. We will check it soon.

I am attaching the sample project , the sablon.xls file and the output generated with the sample project

i am still having the problem

Hi,

Thanks for your project and using Aspose.Cells.

I was not able to replicate this issue at my end. However, I have logged your comments in our database against the issue id: CELLSNET-40995 for investigation.

Once, there is some update for you, we will let you know asap.

Hi,

Thanks for using Aspose.Cells.

We were unable to find any issue with the generated file.

Please download the output file generated by your code, it works fine.

We could not find any reasons why you are having this issue on your system.

Hi,

we have found the problem and want to share with you for your next versions

the problem vas the regional settings, if the settings is not English ( Turkish for our system) the file is corrupted but when we change the culture we have no problem

sincerely yours

Hi,


Thanks for sharing more details.

Well, by default, Aspose.Cells works in English(USA) settings.

Could you give it a try using the following lines before saving the workbook if it works fine, e.g
workbook.Settings.Region = CountryCode.Turkey;
workbook.Settings.LanguageCode = CountryCode.Turkey;

Thank you.