Dear conorpboland,
Thanks for your feedback.
Sorry that the code didn't work on your side. Yet I confirmed the situation you mentioned could work on my side, maybe there was something different between us caused that issue. Please try to use the latest
Spire.XLS Pack Hotfix Version:7.12.76. And below is my entire code and the attachment is my input document.
- Code: Select all
Workbook workbook = new Workbook();
//load a csv file
workbook.LoadFromFile(@"F:\sample document\Data.csv", ",", 1, 1);
Worksheet sheet = workbook.Worksheets[0];
//get the all range on the sheet
CellRange range = sheet.Range[sheet.FirstRow, sheet.FirstColumn, sheet.LastRow, sheet.LastColumn];
range.IgnoreErrorOptions = IgnoreErrorType.NumberAsText;
//also need to set the number format
range.NumberFormat = "0";
//this formula could work
sheet.Range["A20"].Formula = "=SUM(B2+B3)";
//save to excel file
workbook.SaveToFile("11501.xlsx", ExcelVersion.Version2010);
For your second question, please refer to the code below.
- Code: Select all
CellRange lastCell= range.Cells[range.CellsCount - 1];
Hope it helps.
Sincerely,
Betsy
E-iceblue support team