LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Export and preserve Unicode characters into Excel and eventually pdf

Hello all,

 

My objective is to export string data with Unicode characters (specifically the Ω, ≤, and ” characters) through an Excel template (though other formats like Word would work too) into a pdf report.

 

When I used the method in the screenshot (see "Export to Excel and then pdf.PNG"), it seems Excel interpreted the string as ANSI and then converted the string to UTF-8 or equivalent.

I could verify this conclusion by getting the same results when I do the following operations to the unaltered data in Notepad++:

1) Encoding>Encode in ANSI

2) Encoding>Convert to UTF-8

Through the LabVIEW to Excel method as shown in the png and this Notepad++ method I was getting the same alterations of Unicode characters.

The Ω character turned into Ω

The ≤ character turned into ≤

The ” character turned into ” (where, according to Notepad++ method, the  is really the <Operating System Command> character)

 

As a test, if I instead export the data into a text file (See "Export to txt file.PNG"), I can open it with Notepad and all the Unicode characters are preserved as expected. I think this is because Notepad is interpreting the data as Unicode characters as it should.

 

Since Excel seems to think the text is ANSI-encoded, I tried appending a few different BOMs to each string element in the 2D array to get it to recognize the text as Unicode but that didn't work. I also tried using the Save Report to File.vi from the Report Generation library to save as a pdf yielding similar results (I didn't try Print Report.vi yet though).

 

Does anyone have an idea of what can be done to preserve the Unicode characters? I think all Excel needs to do is recognize the data as Unicode text instead of as ANSI. 

 

I am aware of this post regarding Unicode and use one of the VIs from there (UTF8 Encoding to UTF16 Encoding.vi) in my code.

For some reason I need it in order to correctly display Unicode characters on the front panel. Perhaps that fact is related? I'm not sure.

I tried fiddling with some of the other VIs like this person did, but I couldn't get those attempts to work at all. 

 

Sorry for the long post. I would greatly appreciate help of any kind as I'm feeling kind of stuck!

Thank you.

Download All
0 Kudos
Message 1 of 3
(2,422 Views)

You will need to supply more code (VI's rather than png's) to get more help, but can you try using ANSI with particular fonts "such as "Symbol"? Charmap will help here.

If you don't need it to be displayed in LabVIEW, then you could use the UNICODE function of Excel to put the characters in.

0 Kudos
Message 2 of 3
(2,247 Views)

Paul,

Appreciate the guidance.

 

Please see the attached VI and accompanying test text file as input that demonstrates the issue I'm having.

 

To clarify, I am able to display Unicode characters on the front panel. I'm having difficulty exporting the string data to Excel and ultimately a pdf without those characters getting garbled.

 

Thank you!

Download All
0 Kudos
Message 3 of 3
(2,186 Views)