PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Create Excel Spreadsheet from PvxPlus  (Read 922 times)

Tom Anderson

  • Silver Member
  • ***
  • Posts: 26
    • View Profile
Create Excel Spreadsheet from PvxPlus
« 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

Devon Austen

  • Administrator
  • Diamond Member
  • *****
  • Posts: 382
  • Don’t Panic
    • View Profile
    • PVX Plus Technologies
Re: Create Excel Spreadsheet from PvxPlus
« Reply #1 on: June 02, 2022, 09:09:49 AM »
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).

Principal Software Engineer for PVX Plus Technologies LTD.

Tom Anderson

  • Silver Member
  • ***
  • Posts: 26
    • View Profile
Re: Create Excel Spreadsheet from PvxPlus
« Reply #2 on: June 02, 2022, 09:26:37 AM »
Thanks Devon!

I'll give it a try.

Peter.Higgins

  • Diamond Member
  • *****
  • Posts: 124
    • View Profile
Re: Create Excel Spreadsheet from PvxPlus
« Reply #3 on: July 12, 2022, 06:27:56 AM »
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()
 

Tom Anderson

  • Silver Member
  • ***
  • Posts: 26
    • View Profile
Re: Create Excel Spreadsheet from PvxPlus
« Reply #4 on: July 12, 2022, 07:28:08 AM »
Thanks Peter.

I hope you are well.