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.

Example Code

AutoFit Excel Columns and Rows

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
The example is to demonstrate how to open an excel file with the feature of auto fit enabled automatically

Description:
By using the file reference and New Report VI, we could practically make a new report file in the xls format that would be processed into the format of auto fit so by the time the file is opened, the user could face the file represented in the auto fit format

Steps to Implement or Execute Code:
To implement this example:

  1. Define the directory of the file
  2. Run the VI
  3. (Optional) Turn on the Highlight Execution to see the flow of the VI


To execute this example:

  1. Install the required software.
  2. Open the VI and refer the Implement Steps

 

Requirements
Software
LabVIEW 2012 or compatible

Hardware
-

fp.PNG

 

bd.PNG

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

National Instruments
Senior Systems Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
deaw42
Member
Member
on

Sarci1,

    thank you for this VI and guidance with good explanation.

TimsTools
Member
Member
on

The example for LV 2010 worked great.  Uses the active Excel spreadsheet, so simply use the Report Generation Toolkit to select the desired spreadsheet before using this method.  Will attach a VI that workes in flow after this comment.

asukumari
Member
Member
on
What if we want to set the column width to a set value. How do we do that?
NI System Configuration:
- NI PXIe-1071, 4-Slot 3U PXI Express Chassis , 1 GB/Slot throughput, Part Number: 781368-01
- NI PXIe-PCIe8381,x8 Gen2 MXI-Express for PXI Express Interface,3m, Part Number: 782522-01
- PXIe-5160 PXI Oscilloscope, 500 MHz, 10 bits, 2.5 GS/s, 2 Channels, 64 MB, Part Number: 782621-01
- Astronics PXIe-1209 2-Channel, 100 MHz PXI Pulse Generator, Part Number: 785033-01