I am creating an excel spreadsheet using C# (Office Interop). In the Excel sheet I need 600 columns.
The program can write up to 256 columns. After that it gives me a memory error.
How can I write all 600 columns in the spread sheet using my program?
I am happy to use Office Open XML if anybody can provide me an example to convert XML to Excel using Office Open XML (I heard that Office Open XML is better than Office Interop)?
Thanks

Sam HobbsRank #108 · 20.5K reputationPosted Jun 28, 2010, 10:28 AM EDT
Nicholas Barns12 reputationPosted May 14, 2014, 4:13 AM EDT
You see MS Excel is an UI application so its Excel Interop dll was designed for that purpose and because of that API is very slow and consumes a memory pretty fast. You can read here more downfalls of using excel interop in C# applications.
Also here is solution that you can try:
var data = new DataSet();
data.ReadXml("file.xml");
var file = new ExcelFile();
foreach (DataTable table in data.Tables)
{
var sheet = file.Worksheets.Add(table.TableName);
sheet.InsertDataTable(table);
}
file.Save("file.xls");
I used this excel component for C#.