Example Code

Error -2146827284 When Trying to Write Text to Excel Spreadsheet

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 Report Generation Toolkit

    Operating System

  • Windows

    Programming Language

  • LabVIEW G

Code and Documents

Attachment

Description

I spent too much time figuring out what causes error -2146827284. To spare you the time to figure this out yourself, this is what I found out:

 

Goal:

Export some data from a SQL database and write it into a Excel spreadsheet

 

Issue:

The VI "Append Table to Report.vi" returns error -2146827284

 

Cause:

It turns out if you want to write a string starting with an "=" (equal) character followed by more characters, not forming a valid Excel formula, this returns error -2146827284.

 

Possible Solutions:

- Replace the "=" (equal) character

- Prefix the "=" (equal) character with a single quote (') 

 

Error  -2146827284.png

 

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

Comments
crossrulz
Knight of NI Knight of NI
Knight of NI
on

Well, for Excel "=" marks the beginning of a formula.  You then went on to put in an invalid formula.  Use '= instead to state to Excel that you are entering a string that just happens to start with "=".


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Contributors