Using Excel 2013 with C# incorrect row numbers -
i have weird issue in app. copy data excel. have int variable called rowcounter set 1. export data list in excel using rowcounter variable (code below). strange in excel puts data row 10 rather row 1. if change rowcounter 7 excel put data row 70. has else had issue?
when stepping through code can see value of rowcounter expect.
int rowcounter = 1; for(int = 0; < _fundcodes.count; i++) { // code - pulling data database nothing row counter (int m = 0; m < missingauto.count; m++) { _xlworksheet.range["b" + rowcounter + m].value = missingauto[m].fundcode; _xlworksheet.range["c" + rowcounter + m].value = missingauto[m].idsedol; _xlworksheet.range["d" + rowcounter + m].value = missingauto[m].currency; _xlworksheet.range["e" + rowcounter + m].value = missingauto[m].nominal; _xlworksheet.range["f" + rowcounter + m].value = missingauto[m].price; } (int m = 0; m < missingman.count; m++) { _xlworksheet.range["h" + rowcounter + m].value = missingman[m].fundcode; _xlworksheet.range["i" + rowcounter + m].value = missingman[m].idsedol; _xlworksheet.range["j" + rowcounter + m].value = missingman[m].currency; _xlworksheet.range["k" + rowcounter + m].value = missingman[m].nominal; _xlworksheet.range["l" + rowcounter + m].value = missingman[m].price; } int rowadd = missingauto.count > missingman.count ? missingauto.count : missingman.count; rowcounter = rowcounter + rowadd + 2; }
your adding strings instead of numbers:
"b" + rowcounter + m "b" + 1 + 0 "b10"
correct version:
"b" + (rowcounter + m).tostring()
Comments
Post a Comment