Click here to Skip to main content
15,891,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In our application we have used EPPlus to create excel 2007 files. But as per client requirement we had to create an excel 2003 file generation function for same data. We used OpenXML to create excel 2003 file. Now I came up with idea to use the same excel 2007 or xlsx file for both formats. So I used the following code to save the file as xls.
C#
string path = @"D:\" + filename + DateTime.Now.ConvertDateToYYYYMMDD() +".xls";
Stream stream = File.Create(path);
pck.SaveAs(stream);
stream.Close();


Here pck is the EPPlus package which i used to create xls file. I thought it would break because EPPlus doesn't support xls files. But when I opened it in excel 2007 it opens up fine. But the purpose is not solved, because if I open the file in Excel 2003 it shows a corrupted file.

I am now thinking of converting the excel 2007 file to openxml format and then again convert it to excel 2003 file to serve it as openxml xls document which can be opened in excel 2003. Please show some path over this.
Posted
Comments
Richard MacCutchan 28-Oct-15 10:22am    
Changing the extension to xls instead of xlsx will not get the software to convert it to a different format.

1 solution

Neither EPPlus nor the OpenXML SDK support generating Excel 2003 files, which were a proprietary binary format. You'll need to change your code to use a library which supports the older file format - for example, NPOI[^] (NuGet package[^] | Documentation[^]).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900