Link to home
Start Free TrialLog in
Avatar of Jedidia
JedidiaFlag for United States of America

asked on

Writing to excel via Excel Interop

I pull data from a .CSV file that I dump into a multi-dim array.
I reformat array (into the final array) and then create an excel file and set all the column/row formatting.
In the final process, I dump parts of the array into structures columns.
I am using using Excel = Microsoft.Office.Interop.Excel;

The interaction with Excel seems to take longer than it should.

Using Interop to communicate with excel the most efficient/fastest way?

    int j = 2;
    oSheet.Range["A7:P" + rplUpdatedData.GetLength(0)].Borders.LineStyle = XlLineStyle.xlContinuous;
    for (int i = 7; i < rplUpdatedData.GetLength(0); i++)//i for Column index.
    {  

	oSheet.Cells[i, 1].value = rplUpdatedData[j, 0];
	oSheet.Cells[i, 2].value = rplUpdatedData[j, 3];
	oSheet.Cells[i, 3].value = rplUpdatedData[j, 4];
	oSheet.Cells[i, 4].value = rplUpdatedData[j, 15];
	oSheet.Cells[i, 5].value = rplUpdatedData[j, 24];
	oSheet.Cells[i, 6].value = rplUpdatedData[j, 6];
	oSheet.Cells[i, 7].value = rplUpdatedData[j, 26];
	oSheet.Cells[i, 8].value = rplUpdatedData[j, 8]; 
	oSheet.Cells[i, 9].value = rplUpdatedData[j, 28];
	oSheet.Cells[i, 10].value = rplUpdatedData[j, 30];
	oSheet.Cells[i, 11].value = rplUpdatedData[j, 12];
	oSheet.Cells[i, 13].value = rplUpdatedData[j, 26];
	oSheet.Cells[i, 14].value = rplUpdatedData[j, 16];
	oSheet.Cells[i, 15].value = rplUpdatedData[j, 1];
	oSheet.Cells[i, 16].value = rplUpdatedData[j, 2];

	j++;
    }

Open in new window


Thanks
Jed-
ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jedidia

ASKER

Thank you for your input.  
Reading up on open-xml-sdk now!
Glad I could help and all the best.