Jump to content

Problem with writing to multiple excel sheets


Recommended Posts

I have been trying to use ActiveX classes and write to multiple excel sheets.

I was able to create a new workbook but it seems like I keep on getting a run-time error...

Error 98 occurred at Unknown System Error in ExcelWritingDataToMultipleSheet.vi

Possible reason(s):

LabVIEW: Incorrect file type. Attempted to read from or write to a file of a type incompatible with the operation. This normally is a user data file.

I don't really understand the concept of variant types.

If somebody can point out how to fix this, that would be great... Thank you.

ExcelWritingDataToMultipleSheet.vi

Link to comment

Hi,

the error occures because of using the wrong ActiveX class constant at type input of the 'Variant To Data' primitive. Select the class 'Excel._Worksheet' and the conversion will work properly.

Now your example will write values to cell A2 of the worksheet with index 2. If you want to write more than 1 value, you have two possibilities:

- explicitly set '_Worksheet.Range' to a single cell (Cell1 input) which you want to overwrite with the next scalar value. This for each of your values. Advantage: values can be spread all over the sheet. Disadvantage: slower.

- set both inputs, Cell1 and Cell2, of '_Worksheet.Range' to a reasonable value, depending on the amount of data within your data array, to write all the data at once to your sheet. Advantage: faster. Disadvantage: values are written on block.

Regards,

Frank

  • Like 1
Link to comment

I have on different projects had to use Excel ActiveX. My experience is: avoid it, you will get into trouble. The troubles are not unmanageable but frustrating, especially if you need to support different versions of Excel, different languages/localisations, and even different installation options. Maybe you know that you need to use ActiveX, but if you do not, consider using for example a tab-delimited text file, which Excel can read.

69_69.gif

Indeed. Active-X Excel reports are a headache. If your boss can spring $500 for the Report Generator Toolkit from NI it will save you tons of grief and time. I am convinced that the report toolkit will pay for itself in saved time after the first couple of times you use it. Otherwise, like thols said, use a simple tab-delimited text file. Another option is to use the standard report generator VI's and make HTML documents you can save on your network.

  • Like 2
Link to comment

Wow, thank you for all the response.

It is quite an headache to try do something quite simple.

I may consider using a comma delimited file instead...

Still working my possibilities.

Thanks for the suggestions, FrankB and thank you for the code revision, ooth...

It's very clear what I did wrong.

Link to comment

Wow, thank you for all the response.

It is quite an headache to try do something quite simple.

I may consider using a comma delimited file instead...

Still working my possibilities.

Thanks for the suggestions, FrankB and thank you for the code revision, ooth...

It's very clear what I did wrong.

You can use ADO to open, read and write to Excel spreadsheets. See this post.

Place your raw data from LabVIEW on a separate sheet, then reference the raw data from another sheet to perform calculations or chart the data.

  • Like 1
Link to comment
  • 5 months later...

Me also, I had tons of trouble with the Excel reporting.

After a few days I quit.

Now I save to csv (raw data) and jpg (export of graphs) and later on, I create a nice HTML document.

At least the HTML code is "open", and reads +-the same way in all browsers.

The HTML page links to pictures, text, numbers, colors, layout, all generated by the VI.

.

Link to comment

We're some labview beginners having a similar problem. Maybe you guys can help us out.

We're building a similar program just for reading the data out of two keithley 2000 DMMs and making a voltage drop measurement. We're trying to characterize a diode as a project, but we can't get the data to export in a reasonable fashion. We end up getting 1 data point every second or so and the program writes it as its own file. We want a continuous datasheet so that we can analyze the data further.

I've attached it so that ya'll can tweak it as necessary or just give us any pointers.

BJK_3-way.vi

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.