Showing results for 
Search instead for 
Did you mean: 

How can I modify column width in a spreadsheet report without using an Excel template

I currently use the LabVIEW Report Generation toolkit in LabVIEW 2011SP1 to create simple spreadsheet reports that I can build/print without having Microsoft Office products installed.  I really like being able to do this, and it allows me to generate nice on-demand data reports - I'm also not tied to having Office installed on the system I'm using, so this works on just about any test fixture I can install the software on.  


I recently have a requirement that I must have variable-length columns in my report.  I currently use the VI "Append Text Table to Report" in order to create a text table, but the column width requirement is that all columns must be equal width UNLESS I use an Excel Template file to define my column widths.  


My questions are:

  1. Is it possible to create a text table and define per-column widths without using an Excel Template?  If so, how?  My report mainly has a lot of small numerical values for the columns, but some columns contain system names or status messages - I really hate the longer text blocks wrapping and taking up so much real-estate when if I could control the column widths I can get all my data on a single line.
  2. I'll admit I haven't tried this myself yet, but if I use an Excel Template will that require me to have Excel installed on the PC in order to print/generate reports?
  3. Is there a recommended way (with an example) of generating a text table in a report with or without using the "Append Text Table to Report" VI that allows me to have custom column widths that doesn't require me to manually build a custom print page?  If I do have to create a custom print page, what would be the most straightforward approach?



0 Kudos
Message 1 of 6

Are these real Excel files or are they *.csv files that open in Excel?


0 Kudos
Message 2 of 6

What, the template file?  The template file is actually an MS Excel file, as a .CSV does not contain formatting information (only data).  The Report Generation Toolkit uses the column width information properties in the spreadsheet in order to get the information it needs.  However, I don't know if MS Excel is required to be installed in order to determine those properties, or if the toolkit actually knows how to interpret an XLS file format to get that info - my guess would be that it needs MS Excel and uses ActiveX to get the info it needs from Excel.  If my gess is correct, that's not an acceptable solution for what I want.



0 Kudos
Message 3 of 6

Hi Texas_Diaz,


Can you provide a screenshot of your code?  I am having a hard time understanding what it is you are doing / trying to do.  What type of files are created when you run this code without excel?



Andrew T.
National Instruments
0 Kudos
Message 4 of 6

Sure, I'll provide a pared down example that demonstrates my use-case:




I have a control to the VI that takes in a 2D array of strings representing the data I want printed in a table.  I am generating a standard report, adding a table to the report, and printing it.  The first VI is "New", the second VI is "Append Table to", and the third is "Print", all found standard in the Report Generation palette.


Note that the "Append Table to" has an input parameter "Column Width" with a default value of (1).  This input parameter is a single input parameter, which defines the column widths of ALL the columns in my table - hence, with the VI the way it is, all my columns will be 1 inch wide.  


I find myself needing to be able to define per-column widths, not just a single global column width parameter.  


The only way I have found to do this is by using an Excel template file.  The "New" takes in a "template" parameter, and if used, the report generation toolkit can be set to ignore the "Column Width" input parameter on the "Append Table to" by setting the width value to -1.  Instead it will launch Excel, open the template file provided, build the table using the template, will close Excel, and will attach the generated table to the report.  However, I have a strict requirement that Microsoft Office NOT be required to be installed on the computer.  


So, without using Excel, is there a way to generate a table in a report and define the width of each column individually?



0 Kudos
Message 5 of 6

Hi Danny,


Thank you for the code snippet, I have looked into your question a bit more.


The short answer: No, I do not think there is a way to generate a table in a report and define the width of each column individually without using ActiveX with Excel.


The long (and not officially supported) answer:  If you double click the Append Table to icon in your block diagram, you can follow the column width input deeper and deeper into the toolkit arrays.  Keep double clicking on the subVIs that Column Width is tied to until you find a block diagram that looks like this:



Hypothetically, if Column Width here was an array auto-indexed to the for loop, you could set per-column widths as long as the array size matched up with Number of Columns.  HOWEVER, I cannot vouch for certain if this would work properly and if you overwrite the original VIs, you could really mess up your toolkit functions.  Only jump into these if you are very confident in what you are doing.

Andrew T.
National Instruments
0 Kudos
Message 6 of 6