06-27-2007 04:02 PM
06-28-2007 01:16 AM - last edited on 06-03-2024 09:57 AM by Content Cleaner
Hi EduMIT,
there are several ways to export formatet text to other programs. If you have the report toolkit (https://www.ni.com/en/shop/labview/select-edition.html), use those VIs. You can also use ActiveX controls. This offers kind of remoting other programs like MS Word.
Sometimes ActiveX is not documentated clearly, so you need some examples and some time to try it out.
An other possibility is to use standard function: Funtions>All Functions>Report Generation. On this way you could export test into html documents.
06-28-2007 12:28 PM
Hello Sparti,
Thank you for your suggestions, they are all very useful, and I plan to use the HTML feature under Report Generation to export the formatted text from Labview. However, I am still not sure how I can extract the formatted text from a *string indicator* and transfer it to one of those VIs, so that it can be exported to other applications. Let me give some more specific info on what I am trying to achieve: I am monitoring the communication between two pieces of equipment. A string indicator shows all the data flow, with different colors for data coming from different instruments. I managed to do that by using a property node and playing with the selection and font color properties. Now, if you just wire the output of the string indicator, the formatting is gone and all you get is just plain black text (for instance, try to programmatically transfer the formatted text from one string indicator to a different string indicator and you will see that the formatting is not preserved). Even if you try the "brute force" method of manually selecting and copying the text in the indicator and pasting it to Word, LV does not export the formatting. But, if you paste *within* LV (for example, paste it to a string constant in your diagram), then it works. To extract the formatted string from the indicator, I also tried to use a property node, but without success. I am trying to avoid duplicating part of my code to generate the same color-coding scheme on a report. It would be way easier to be able to transfer the formatted text from the string indicator. This is particularly annoying, because the information is there, stored in the data structure associated with the string indicator. But how can I put my hands on it? Any ideas?
06-29-2007 01:54 AM
Hi EduMIT,
the way you want to transfer your datas does not work. This because the value in string does only contain letters, and no format. If you want to transfer format from one indicator to another, you have to work wirth property nodes. So you just read out all necessary format settings form the source indicator (by property node) and transfer those datas to the target property node (eg colors, text size, bold and so on).
An easier way could be to fill all datas (like passed/failed, complete/reading, value, unit ...) in a table (in the background and not visible for the user). From this table you could uptate a specific indicator (eg: value = n, status = failed -> red and bold, ...) by a method. If you want to transfer datas, just read this table out by the same method reapplying on an other indicator. This way is encapsulated, upgradable and clearly arranged.
12-10-2021 02:30 AM - edited 12-10-2021 02:35 AM
Was just looking into this as well.. have a more complicates use case.. formatting for string is not the same everywhere as sections can be modified (see link below).
Thinking of just scanning the enitre string and then turn it in html/rtf. Anyone already some experience with this?
Copy to clipboard doesn't work using the standard function.. it remains plain text.. soo more looking into that as well
12-10-2021 05:15 AM
You can loop over each character, using selected text:
You'd have to read each property of interest and manage state changes and translate it to some formatted string (like HTML or something custom).
This will get complex fast...
Can you explain the use case? E.g. during development you can simply copy the control\constant, and formatting will be copied.
12-17-2021 03:55 AM
Hi Wiebe,
This was indeed the approach I had in mind. Something like below where the entire Text.Font cluster is compared to previous value. When defering panel updates I think for small texts this would be possible.
If I am going to implement something like this I will add the solution code to this forum. Just converting it to some raw HTML shouldn't be that complicated. Only a few parameters to process.
About the use case. I am making a script interpreter, where I will also add some syntax highlighting and debugging highlighting.
For documenting, I tried to copy & pasting the formatted text into word and such for documenting. This looses all formatting.
Formatting is kept when copied within labview from one control to another.
12-17-2021 04:54 AM
@beuvink wrote:
Hi Wiebe,
This was indeed the approach I had in mind. Something like below where the entire Text.Font cluster is compared to previous value. When defering panel updates I think for small texts this would be possible.
If I am going to implement something like this I will add the solution code to this forum. Just converting it to some raw HTML shouldn't be that complicated. Only a few parameters to process.
About the use case. I am making a script interpreter, where I will also add some syntax highlighting and debugging highlighting.
For documenting, I tried to copy & pasting the formatted text into word and such for documenting. This looses all formatting.
Formatting is kept when copied within labview from one control to another.
You could consider using .NET controls.
I never did that, but I'd thing copy-pasting from a .NET rich text control to office might be seamless. You wouldn't have to catch copy events, convert the text, and get the formatted text on the clipboard.
It could be a dead end.
12-17-2021 05:27 AM - edited 12-17-2021 05:41 AM
This was the approach I was thnking on for in order to copy to clipboard.
The labview clipboard function is text only. So when copy/paste HTML in this way it pastes in office as plain HTML code.
rtf specification is much more complex then HTML. Checking .net documentation I can see a method where you can copy to clipboard with type description.
However this seems like a dead end.. or do you have some other trick under your sleeves.. otherwise I will go for 'write to file', 'open file in browser', 'copy & paste' from there. Good enough for documentation.
Without constructor I get some error I didn't investigate further (same error with get text, just using clear as this is the most simple method)
12-17-2021 05:51 AM - edited 12-17-2021 05:58 AM
Clear is static, so don't wire a constant (no need to).
The error will give you:
System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made.
Go to VI properties and in Execution, set Preferred Execution System to "user interface".
It will clear the clipboard.