LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

reading values from excel to table in CVI

hi,

i am reading rows and column value from excel to table. i am not getting the text display completely as per in excel cell. do i need to change any cell attribute or how to do to get the full text to be displayed. pls view the below table,

here in the 2nd column i need to view the text fully for all the cells. how it is done????

 

table.JPG

0 Kudos
Message 1 of 5
(4,082 Views)

I'm not aware of any method to automatically adjust column size to cell contents.

What you may want to do is to calculate the expected text width for the cell text and manually adapt the column width to it. To obtain this:

  1. Create a Metafont with CreateMetaFont () function
  2. Iterate on all cells in the column and retrieve their texts (alternatively, iterate on the array of strings retrieved from Excel sheet)
  3. Calculate each text width with GetTextDisplaySize ()
  4. Calculate maximum width
  5. Set column width with SetTableColumnAttribute (..., ..., VAL_TABLE_COLUMN_RANGE (column), ATTR_SIZE_MODE, VAL_USE_EXPLICIT_SIZE) and SetTableColumnAttribute (..., ..., VAL_TABLE_COLUMN_RANGE (column), ATTR_COLUMN_WIDTH, maxWidth)

 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(4,075 Views)

hi is their any other way to display the text without going for metafont. i am retreving data from excel to table through the function ExcelRpt_ReadDataToTableControl().

 

0 Kudos
Message 3 of 5
(4,071 Views)

Not that I am aware of.

It is to be said, though, that I never used Excel report functions, so I may be missing some useful characteristic of that instrument.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 5
(4,066 Views)

There is a CVI function, SetColumnWidthToWidestCellContents, that you can call on each of your columns, after you have converted your table, which should auto-size each column to its ideal size.

 

Luis

 

Message 5 of 5
(4,046 Views)