PxPlus User Forum
Main Board => Discussions => Programming => Topic started by: Tom Anderson on June 01, 2022, 10:44:58 PM
-
I have a grid with 10 columns and would like to be able to send the data to an Excel spreadsheet from within my PvxPlus program.
I have reviewed the PvxPlus manual but can't seem to get the syntax right.
Could someone give me some simple syntax to create a new sheet (or open an existing sheet), write the data to the sheet and save it.
Any help would be greatly appreciated!
Tom Anderson
-
In the doc for the Excel object there is an example program at the bottom that demonstrates a lot of the functionality. It shows opening a workbook and setting the active worksheet and reading and writing to it. https://manual.pvxplus.com/?PxPlus%20User%20Guide/External%20Components/PxPlus%20COM%20Support/Excel%20Object.htm
Creating a sheet is easy just use the CreateWorksheet method.
x'CreateWorksheet("My New Sheet")
this will create a new sheet that is inserted before the active sheet.
Another option is you can enable the right click menu for the Grid which has a export to excel option. Then a user just has to right click and select the option to export to excel and you don't have to write the code. The listbox/grid right click menu is controlled via %list_popup (https://manual.pvxplus.com/?NOMADS%20Graphical%20Application/Creating%20Panel%20Controls/Popup%20Menu/List%20Box%20and%20Grid%20System%20Popup%20Menu.htm).
-
Thanks Devon!
I'll give it a try.
-
Tom,
Writing to Excel can be slow. The fastest way I've found is to use the excel PasteSpecial() command which is fast and works on windows and Linux. This doesn't require the sheet to be in the foreground to catch errant keystrokes.
CLIP_BOARD WRITE data$
SheetObjectHandle'RANGE(R$)'PasteSpecial()
-
Thanks Peter.
I hope you are well.