c# - Insert [,] string array into a excel sheet -
i have [,] string array 40 rows 40 column items. trying write them excel sheet output keeps writing same word on first row of every column. doing wrong?
public static void writetofile(this string [,] result) { try { //open instance of excel microsoft.office.interop.excel.application app = null; app = new excel.application(); app.workbooks.add(); excel._worksheet sheet = app.activesheet; sheet.name = "sheet 1"; int resultcount = result.length; (int = 0; < 40; i++) { (int j = 0; j < 40; j++ ) { sheet.cells[i].value = result[i,j]; j++; } i++; }
if got array rows @ first dimension , columns @ second dimension, can write:
sheet.range[sheet.cells[1,1], sheet.cells[40,40]].value = result;
Comments
Post a Comment