LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Report - Problem with writing strings in scientific notation to an excel file ("3E04")

Solved!
Go to solution

I'm trying to write hex strings to an excel file using Excel Report, but I came across cases where the string happens to be in scientific notation ("3E04"). The excel file interprets "3E04" as 30000. I'm using SetCellValue to write to the file and I've specified that the type is a string. I understand that from Excel it is possible to format cells to be straight text, but how can I do that from CVI, such that it is interpreted as text and not numeric?

 

This is my code:

ExcelRpt_SetCellValue(OutputWorksheet, "A1", ExRConst_dataString, "3E04");

 

I'm using LabWindows CVI 2013 and MS Excel 2007 

0 Kudos
Message 1 of 4
(2,772 Views)
Solution
Accepted by topic author Mikeyws

Can you try prefixing the hex string with a ' character. So 3E04 will look like '3E04. That works when I want to type a hyphen (-) in a cell to show it is empty and Excel tries to use it as a minus sign and start doing math. In that case Excel does not change mode, and prints only the - not the '

Hope this helps

S. Eren BALCI
IMESTEK
Message 2 of 4
(2,743 Views)

When I cannot change cell type from CVI, I create a template file formatted according to my application and clone that file first and then fill it with values.

That might not work for your application if data sizes vary from run to run. But otherwise it may solve your problem.

Or you can use Excel library, not ExcelRpt, which is a bit more difficult to use.

S. Eren BALCI
IMESTEK
Message 3 of 4
(2,741 Views)

Thank you so much, ebalci! It worked perfectly!

0 Kudos
Message 4 of 4
(2,708 Views)