Problems Opening After Converting CSV to XLSM

Hi,

I am using Cells to convert CSV files to Excel files with the capability for macros. After one run, the documents open fine, but if I run again there is an Excel error saying “We found a problem with some content in filename. Do you want us to try to recover as much as we can? If you trust the source of the workbook, click Yes.”

I am doing my development in WinForms C#, and the goal is to have these files update on a button push and then the macro run automatically when the data is changed. What could be causing the issue when I run more than once? Here is the outline of my code:

            var workbook = new Workbook(path1Csv);
            FileStream outFile1 = new FileStream(outPath1Xlsm, FileMode.OpenOrCreate, FileAccess.Write);
            workbook.Save(outFile1, SaveFormat.Xlsm);
            outFile1.Close();

            workbook = new Workbook(path2Csv);
            FileStream outFile1 = new FileStream(outPath2Xlsm, FileMode.OpenOrCreate, FileAccess.Write);
            workbook.Save(outFile2, SaveFormat.Xlsm);
            outFile2.Close();

…etc.

@EvanLacey,

Thanks for the details.

We need your sample files and complete code snippet to reproduce the issue. Please provide us a standalone sample console application and resource files (input file(s) and output file(s)) to simulate the issue. We will check your issue soon.

PS. please zip the project and files prior attaching here. You may also exclude Aspose.Cells.Dll to minimize the size of the zipped archive.

I actually solved the issue by changing FileMode.OpenOrCreate to FileMode.Create. Not the most intuitive thing, but the description for FileMode.Create is a file will be created if it doesn’t exist or will be overwritten if it does and that’s exactly what I needed. Thanks for the fast response.

@EvanLacey,
I’m glad your issue has been solved. If you have any questions, please feel free to contact us.

Please provide us a standalone sample (console) application with sample (resource) files (input file(s) and output file(s)) to simulate the issue. We will check your issue soon.

PS. please zip the project and files prior attaching here. You may also exclude Aspose.Cells.Dll to minimize the size of the zipped archive.