Jim Schwetz
asked on
Get Values of cells in a column with formula using C# to paste to another column. (The formula is to remove the apostrophe in front of the number)
Issue -
I am using OfficeOpenXML package in C# to process excel files.
I am not able to read values from the cells with formula, it returns empty string.
I am setting up the formula in the field-
worksheet.Cells["I2"].Form ula = "=RIGHT(H2, 9)";
but when I am trying to get the value of cell with formula, I am getting blank value, but the excel file shows value -
string cellValue = worksheet.Cells["I2"].Text
excelHelp.xlsx
I am using OfficeOpenXML package in C# to process excel files.
I am not able to read values from the cells with formula, it returns empty string.
I am setting up the formula in the field-
worksheet.Cells["I2"].Form
but when I am trying to get the value of cell with formula, I am getting blank value, but the excel file shows value -
string cellValue = worksheet.Cells["I2"].Text
excelHelp.xlsx
I haven't worked with OfficeOpenXML, but you might try this. In a quick look online it looks like you can address the cell by it's row column text address as you are doing so that should be okay.
string cellValue = worksheet.Cells["I2"].Valu e.ToString ()
Are you sure worksheet is referencing the sheet you think it is?
»bp
string cellValue = worksheet.Cells["I2"].Valu
Are you sure worksheet is referencing the sheet you think it is?
»bp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks all, I will try these tomorrow, and thanks gr8gonzo for the trimStart with C#, That sounds like a smarter way of doing it.
worksheet.Cells(2,9).Text
Where 2 is the row index and 9 is column index for column I.
OR
worksheet.Range("I2").Text
Also, I assume that worksheet variable is properly defined.