From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Random Ramblings on LabVIEW Design

Community Browser
Labels
cancel
Showing results for 
Search instead for 
Did you mean: 

ODT Update - Now with extra table-age

swatts
Active Participant

Hello LabVIEW Friends,

Thought I would share an update to my Open Document Toolkit with you all,

One day I'll stick it on git, but git makes me sad...

 

I've been updating some old Laboratory Management code I wrote in LabVIEW 8.5 and one of the task was to print a report with tables in it. In the old code I used the report generation toolkit, but sadly NI have updated it so that it doesn't work now.... (nice)

 

I also want IT away from my system, so don't want Microsoft Office near my machines...

 

A perfect use case for my ODT toolkit

 

You can find more about this kit here -

30 - OpenDocument Format

79 - Open Document Toolkit

81 -  Open Document Text Document

181 - OpenDocument Format Session

 

The requirement was to be able to place a table of unknown dimensions onto a report, with the ability to adjust column widths and add column headers.

This whole toolkit is based on making a template with named book marks dictating where stuff goes. I use LibreOffice to create my templates.

 

As discussed in previous articles an open document file is just a zipped up folder (with 1 caveat!) with the contents as below.

ODTFile.png

We're interested in updating the styles.xml and content.xml files for tables. I can't be bothered to share the XML, have a look in the source-code if you are that interested.

 

I've created a new example called ODTableExample.vi

ODTable.png

And here's the source..

ODTableBD.png

With the new method for adding a table at the table at BM "TableBM".

 

One bit of code I like was that I needed to at style names, to ensure they were unique I would use a regex to find all the instances. I would then take the max value and add 1 to it. It works rather well.

 

ODTableRegex.png

For those unfamiliar with regular expressions (regex), they are a nifty and efficient way to find things in text. In this case I was looking for sentences that included {<style:style style:name="P} and up to 6 digits after that but before {" style:family="paragraph"}, which is the regular expression "\d{1,6}". I tested it with https://regex101.com/

 

All written in LabVIEW 2018.

 

Hope everyone is well

Lots of Love

 

Steve


Opportunity to learn from experienced developers / entrepeneurs (Fab,Joerg and Brian amongst them):
DSH Pragmatic Software Development Workshop


Random Ramblings Index
My Profile