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.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate an excel file?

Solved!
Go to solution

You should use these settings to save your file:

 

Excel_WorkbookSaveAs (ExcelWorkbookHandle, NULL, file_name_Variant,
                                                 CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                                 CA_DEFAULT_VAL, CA_VariantBool(VFALSE),
                                                 CA_DEFAULT_VAL, ExcelConst_xlNoChange,
                                                 CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                                 CA_DEFAULT_VAL, CA_DEFAULT_VAL);

0 Kudos
Message 21 of 38
(1,853 Views)

Hi;

Kindly, can you give me help or each parameter of those two functions;

Excel_WorkbooksOpen

 

Excel_WorkbookSaveAs

Every time when i want to change any parameter, i don't what to put in each one, and i don't any information in the "help";

Many thaknss 🙂

0 Kudos
Message 22 of 38
(1,849 Views)

hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiSmiley Tongue

0 Kudos
Message 23 of 38
(1,833 Views)

Informations on SaveAs can be found here: CVI exposes an interface to this function into his instrument. On Microsoft site you can find informations on all other functions you may be using.



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 24 of 38
(1,831 Views)

hi,

pls, i can't finish that project ohhh my GOD!

i succeed to do all, but when i open existing workbok, the system open it for read only, and i passed (file not for read olny) in parametres!!

honestly don"t understand why;;

need to re open existing file and write datas into it and close it with datas qlready written;

Help pls;

 

0 Kudos
Message 25 of 38
(1,822 Views)

Hello touha,

some questions on your last problem:

 

  1. Have you tried with the excel example project, which opens an existing file and writes to it? Does it shows the same problem?
  2. Are you sure your excel file is not marked as read-only? And that is not already opened in Excel or another application? Or by another user in your network?
  3. Is the file on your local disk or on a remote unit? Have you full authorizations on that unit?
  4. Have you tried with a small project with only Excel functions?

If all your attempts were unsuccessful, can you post the code you use to open the file?



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 26 of 38
(1,824 Views)

Good morning dear Roberto;

So, for the part of "writing data into excel file":

Every second, i've to read data from RS232 port, then write it into an excel file;

A new excel file have to be created every day, means the frist time i launch application, the xl file will be created, and then while the application is unning, every data readed have to be written into that file and when i quit the application, the file have to be saved;

I already used the method founded on excel sample on CVI, but it doesn't work ;

Every time, when i run application, i see the file opened, i see th e data writen into it and all is weell, but when i want to quit the application, it shows me a window that ask me to save the file as a copy of the file, and on the top of the xl file, it's for "read only";

Note, that when i close all without saving, i found the file created, but it's empty;

I tried to delete it, for example, i can't, a window tell me that it 's used by my computer, the processus "xl" is used by another one....

Really need help ASAP, 🙂

0 Kudos
Message 27 of 38
(1,819 Views)

How you "see" data written into the file? Are you opening the file in Excel at the same time you are writing to it with CVI? What happens if you don't do it?

 

When working with ActiveX it is crucial that all resources are correclty disposed of when they are no longer needed. In order to check this detail follow this procedure:

 

  • Restart your computer and verify that Excel is not running by examining the Processes tab of the Task Manager
  • Run your application and only that one for a few time and then close it: as far as I can understand it should create the file, write some data and then save it
  • Examine running processes after your program has closed: no instance of Excel must be running. If you see some, it means you have not cleared some of the handles used in your program
  • Open the file in Excel and check how it appears

 

 

By the way, "every second" means 86400 recordings per day: supposing you are using one row per recording you need to use a recent version of Excel. At least up to Excel 2003 you are limited to 65536 rows.



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?
Message 28 of 38
(1,810 Views)

I run the example excel2000dem.prj and there's nothing wrong with saving the file.

The only things that I changed are: 

1) Remove the "Read-Only" setting of the "exceldem.xls" so that it can be modified.

2) Use the function below that associated with the "Close File" button in the UIR.

          Excel_WorkbookClose (ExcelWorkbookHandle, NULL, CA_VariantBool(VTRUE),
                                             CA_DEFAULT_VAL, CA_VariantBool (VFALSE));

 

That's it.  You don't even need the SaveAs function.  The modified excel file will be saved and closed automatically.

Message 29 of 38
(1,794 Views)

Good morningg;

MAny many thanks for dcl91000 and Roberto Smiley Happy

So, i succeed to do it well, and it works 😉

Now, i've another issue, i've to display max & min into the xl file, of the whole 24 hours, means every time when i quit the application, i've to keep the values of max & min into memory, to use them again when i run the application another time;

Actually, i used files to save every value into it, and when i run the application agoing i read that value and use it in my prog=> But like that i've many many files 😞 it becomes very hard to manage...

I tried t save them into one file means write from array to file and then read from file to array, but that doesn't work wel, look like the value is not updated into the file when i write from array to file...

Have you any comments 🙂

0 Kudos
Message 30 of 38
(1,779 Views)