excelize icon indicating copy to clipboard operation
excelize copied to clipboard

GetCellValue does not return raw value, even with the option RawCellValue: true

Open ffleader1 opened this issue 2 years ago • 6 comments

Unless I am reading the doc from, I suppose by passing the GetCellValue with the option RawCellValue set to True:

	cell, err := f.GetCellValue(sheet, cellLoc, excelize.Options{
		RawCellValue: true,
	})

I can get the raw text of what has been written in the cell. Does not seem to be the case though. The above line would gimme me the result of the formula, a number, in var cell but I need is the formula string, like =SUM(O4,N4) So, is this a bug, or am I not looking correctly, in which case what should I do to get exactly what has been written in the Cell? Thank you

ffleader1 avatar Feb 28 '22 19:02 ffleader1

Thanks for your issue. Please use SetCellFormula to get the formula from the cell and use GetCellType to determine which cell is a formula cell.

xuri avatar Mar 01 '22 02:03 xuri

Thanks for your issue. Please use SetCellFormula to get the formula from the cell and use GetCellType to determine which cell is a formula cell.

You mean to use GetCellFormula right? Well, the thing is if the Cell contains =SUM(O4,N4), then the formula will be O4+N4. I need the formula string due to the fact that that my Cell has LET function, which cannot be parsed (yet), so I need the raw string formular to run it through a custom LET parser that I wrote. But I cannot because if the formula has LET, it will not work properly. But I cannot get the raw string formular. Basically, I just want to know how (or is it possible) to get the Raw string fomula. Thank you.

ffleader1 avatar Mar 01 '22 03:03 ffleader1

Any update on this? I just want to get the raw raw formular, not the formula that has been passed. Thank you.

ffleader1 avatar Mar 01 '22 17:03 ffleader1

I have possibly a related issue; I have 24-hour times in a column which even with RawCellValue set are returned without the leading zeros instead of the text "0050", for example.

pgalbavy-itrs avatar Jul 26 '22 15:07 pgalbavy-itrs

Hi @pgalbavy-itrs, thanks for your feedback, could you provide your input file attachment without confidential info?

xuri avatar Sep 09 '22 05:09 xuri

Will try - it turned out the cell was formatted by the user with some weird combination of languages and numeric types. I will have to go find a copy of the XLSX file before they fixed it on our advice.

Found it; Will try to put value and format in it's own file - but under OneDrive cell format is:

image

Yes, we don't know who picked that either.

pgalbavy-itrs avatar Sep 12 '22 11:09 pgalbavy-itrs