tags:

views:

297

answers:

4

I have an application that write huge .csv files about the size ranging from 1 GB to 2 GB.

I need to color code the file and save it as .xlsx.

So I have tried using Excel Interop and it works great for small files, but when I try to open a 1.3 GB .csv file with Excel, I get an Hresult error.

Any ideas as to how I could accomplish this task either with using Excel, or if there is any other way of doing it.

A: 

There are ways to write and read excel files without using the excel interop. I'm pretty sure I remember microsoft themself have open specifications on the excel fileformat.

Jonas B
Ah never mind, it's probably like above said, split the files.
Jonas B
+4  A: 

Are you exceeding 1M rows ? Maybe thats the reason for the HRESULT error.

64K rows max before Excel 2007. 1M rows for 2007

renick
Excel 2007 also maxes out? I'd heard "unlimited" from a coworker, but I guess they just didn't have enough data! ;)
FrustratedWithFormsDesigner
http://office.microsoft.com/en-us/excel/ha100778231033.aspx - In Excel 2007, the worksheet size is 16,384 columns by 1,048,576 rows, but the worksheet size of earlier versions of Excel is only 256 columns by 65,536 rows.
Joe
@FrustratedWithFormsDesigner: Surely Excel 2007 has a limit as well, any machine has limited resources (and one boundary here is the 2 GB memory limit for a 32-bit process). In fact, large Excel sheets are one of the reasons that there is now a 64-bit version of Office coming with Office 2010.
0xA3
A: 

Thanks for the responses guys, after thinking about it, I have decided to simply use the .csv file.

A: 

If using Excel is your problem. I have used a component from Syncfusion in the past called "Essential XlsIO". It can be used to read/write and create Excel files from scratch. I used this to avoid issues with having to use Excel interop in a server environment.

I used their component to add colour-coding and comments to spreadsheets to indicate validation errors as part of a spreadsheet upload process.

It can be used to create spreadsheets from scratch. Very nice product it was too, although I did not try it with the data sizes you mention.

http://www.syncfusion.com/products/reporting-edition/xlsio

chibacity