LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RGT add_sheet module error

Solved!
Go to solution

My purpose is simple , just to write several sheets in one book and rename the sheets.

 

I made a clutch array , each clutch contains three elements ,see as below(please ignore the numerical value,they may be uncorrect):

微信截图_20180429165421.png

 

what I want is like the excel book as below:

微信截图_20180429170100.png微信截图_20180429170112.png微信截图_20180429170123.png微信截图_20180429170132.png

 

I creat a diagram to achieve that,see as below:

微信截图_20180429170427.png

 

It seems everything is OK,each step in the FOR loop I add one sheet and rename the sheet and write data into the sheet. but once I RUN the VI,error appear, and give me an empty excel document,see as below:微信截图_20180429171724.png

 

微信截图_20180429170653.png

 

What shall I do ? I really need to write the array into one book ,because thay are closely related. (If I creat four excel documents and just use the first sheet of the documents , it works fine ,but this is not what I want ,I want write them in one document with 4 sheets)

I remember I had ever succeed for such operation , I am not sure whether I had changed the code

0 Kudos
Message 1 of 6
(1,350 Views)

I recently wrote a routine that took data from a number of stations and created an Excel Workbook with one WorkSheet per station.  Here are the steps I took:

  1. When I opened the WorkBook by doing a New Report with the desired WorkBook path wired to the Template input, I then used Excel Workbook Properties to get the number of WorkSheets (I expected it to be 3, but better Safe than Sorry).
  2. Collect (in an Array) information pertaining to each WorkSheet to be created.  This can be a list of PathNames for existing data sets, the data themselves, or however else you want to organize it.
  3. The For loop that processes the data puts each one on its own WorkSheet, whose name is set according to the Data (it could be the name of the DataSet, the Path Name from which the Data are taken, or simply Sheet 1, Sheet 2, ...).
    1. The first step is to compare the index of the For Loop (0, 1, 2, ...) with the number of WorkSheets currently in the WorkBook.  If there is already an existing Sheet (i.e. for a 3-sheet WorkBook, for index 0, 1, and 2), use Excel Get WorkSheet to make that Sheet "current".  Otherwise, do Add WorkSheet.
    2. Now initialize the WorkSheet (including renaming it as appropriate) and put whatever data you want on it.
  4. When you are all done with writing WorkSheets, Save Report to File using the FileName you chose.  I then Dispose Report.

I've found that before and after doing a Dispose Report when dealing with Excel, it is often a good idea to put a short "wait" of a few hundred milliseconds.  Sometimes Office gets "cranky" if you try to process multiple reports in a row.

 

Bob Schor

0 Kudos
Message 2 of 6
(1,317 Views)

It seems any deeper operation always enconter error. my OS is WIN7 32bit and LaBVIEW2015 and Excel 2007.

 

微信截图_20180430115257.png

 

0 Kudos
Message 3 of 6
(1,300 Views)

Well, I can't examine the code (you failed to attach your VI), cannot read the Error Message, but can note that you are running a peculiar system, based on a 32-bit version of Windows 7 (most of us run 64-bit Windows 7 or 10), a fairly modern version of LabVIEW (2015), but a very old version of Office (2007, superceded by 2010, superceded by 2013).  The two functions you show fail to connect the Error Line between them, and fail to terminate the Error Line in an Error Terminal.  For which of the two functions did the Error occur?  Do we know if a suitable Excel file exists?  Do we know if it contains at least two WorkSheets?

 

Bob Schor

0 Kudos
Message 4 of 6
(1,287 Views)

It may really be the reason of the software version compatibility that caused the error. After reinstalled OFFICE 2010, everything turns OK.

 

I consider that NI should give an instruction of the compatibility of them.

0 Kudos
Message 5 of 6
(1,279 Views)
Solution
Accepted by topic author alii001

@alii001 wrote:

It may really be the reason of the software version compatibility that caused the error. After reinstalled OFFICE 2010, everything turns OK.

 

I consider that NI should give an instruction of the compatibility of them.



NI has little control over the internals of Microsoft Office.  "Keeping up with the Latest" of another company's proprietary code, especially trying to maintain compatibility with older versions, is not their Main Mission.  In general, it is a good idea to have the OS, the LabVIEW Version, and ancillary Routines at a similar release level.

 

One thing to note -- problems have been noted with Excel 2016, and "fixes" have been posted on this Forum.  I'm using Office 2013, myself, and have not encountered these issues ...

 

Bob Schor

0 Kudos
Message 6 of 6
(1,274 Views)