Drawing shape needs to be repaired after open and save template file with Aspose

Hi,
Opening and saving a specific template Excel 2007 file results in unreadable content.
I get no runtime errors but when I open the resaved file Excel tells me it has unreadable content:
Excel found unreadable content in ‘result.xlsx’. Do you want to recover the contents of this workbook?
Repaired Records: Drawing from /xl/drawings/drawing5.xml part (Drawing shape)

This is the code to reproduce:

//using Aspose.Cells;
Workbook book = new Workbook();
book.Open(Request.PhysicalApplicationPath + @“ExcelTemplates\InmatningMymanagement20081124.xlsx”);
book.Save(Request.PhysicalApplicationPath + @“ExcelTemplates\result.xlsx”);

I have attached the Excel file

I am using version 4.6.0.0 of Aspose.Cells

Please have a look and see if you can find out what is going wrong.
Thank you!

PS. Don’t know if it helps but I found a similar thread where the problem was resolved: Pivot table needs to be repaired after open and save template file with Aspose
I couldn’t try this fix since the fix was sent to the original poster only


/Anders

Hi,

Thank you for considering Aspose.

As your file is in Excel 2007 xlsx file format, so you should specify the FileFormatType.Excel2007Xlsx as second parameter, when opening and saving your workbook. I checked the file with the latest version of Aspose.Cells and it works fine. Please see the following sample code,
Sample Code:

Workbook book = new Workbook();

book.Open(Request.PhysicalApplicationPath + @"ExcelTemplates\InmatningMymanagement20081124.xlsx", FileFormatType.Excel2007Xlsx);

book.Save(Request.PhysicalApplicationPath + @"ExcelTemplates\result.xlsx", FileFormatType.Excel2007Xlsx);

If you don’t provide the second parameter then the default file format of a workbook is Excel 2003. If you still face any problem in your current version, please try the attached latest fix.

Thank You & Best Regards,

Thanks for your quick response! I tried the sample code provided but the problem is still there. I also tried it with version 4.6.0.9 but it didn’t help. Strange that we get different results.

My environment is Vista and Visual Studio 2005 (ASP.NET 2.0 sp1).

Do you have any other ideas that I could try?

Thanks.

Hi Anders,

Thank you for providing further details, but we are not very clear about what actually the problem is? So, please create a sample console application to replicate the problem with the Aspose fix you are using. Zip that application and post it here. This way it will be easier for us to figure out the actual problem.

Thank You & Best Regards,

No problem, here it is.

When I execute this program it runs fine but the created Excel file (result_xxx_.xlsx) is broken when I open it in Excel.

Excel files are opened from and written to the project folder.

Best regards, Anders

Hi Anders,

Thank you for providing us the sample console application. Well, we are not getting any error in opening the file generated by your provided application and template file. I have attached my generated file against your template file and sample code. Please try to open it and check if it gives you any error or not. If you don’t get the error message, then there might be some issue with an image which is not converted from your template file into the generated file in sheets “MyManagement” and “MyManagement 360” (Three Circles “Individuella” etc at the bottom). Try to remove that image from both sheets and try to generate the file, if you still find the problem, please let us know and we will check it further.

Thank You & Best Regards,

Great news!
In the sheet “Beräkning MMP” I deleted 3 graphs (located at AY260) and then everything worked fine.
Since these graphs are not crucial to the Excel file this means I can use Aspose.Cells!

I am still curious as to why we got different results. The Excel file you posted here worked absolutely fine.
I tried my code on 5 different machines (Vista, XP and Windows server 2003) and could reproduce the problem in all environments. Even when running a published .exe version of the code. Perhaps it has to do with language settings (mine are swedish) or some other environment variable?
There is no need though to dig deeper as my client is happy.

Thanks for you help!
Best regards, Anders