I just started implementing this to populate an Excel sheet with some data:
using OfficeOpenXml;
//..
ExcelWorksheet VerificationSheet_Sheet4 = package.Workbook.Worksheets.Add("SheetTitleHere");
int row = 0, col = 0;
VerificationSheet_Sheet4.Cells[row + 1, col].Value = "AnyStringHere"; // error here
However it pops an error saying column is out of range. Why and how can I fix that?
Excel worksheets use 1 based indexing rather than zero based. Thus columns and rows both start at 1 and not 0.
As per the elaboration by @Darren Young Excel uses 1 based indexing thats where the issue is.
using OfficeOpenXml;
//..
ExcelWorksheet VerificationSheet_Sheet4 = package.Workbook.Worksheets.Add("SheetTitleHere");
int row = 1, col = 1;
VerificationSheet_Sheet4.Cells[row + 1, col].Value = "AnyStringHere";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With