PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Excel Spreadsheet Column Options  (Read 1109 times)

Ron Klassen

  • Member
  • **
  • Posts: 16
    • View Profile
Excel Spreadsheet Column Options
« on: August 30, 2022, 12:29:32 PM »
Using the excel object is it possible to change the cell format? For example, I would like to change the format for all cells in column 1 from general to text.

RobL

  • Silver Member
  • ***
  • Posts: 21
    • View Profile
Re: Excel Spreadsheet Column Options
« Reply #1 on: August 30, 2022, 06:24:22 PM »
Hi Ron,

I don't see a property or method of the *obj/excel object you could use to change the cell format, but there is the 'Excel property that give you access to the properties and methods of the Excel object.

The following works for me (PxPlus 2022 Windows):

begin
xl=new("*obj/excel")
wb=xl'OpenWorkbook("ExcelSS.xlsx")
ws=xl'SetWorkSheet("Sheet1")
xl'Excel'Columns("A")'NumberFormat$="@" ! set column 1 to text
xl'SaveWorkbook()
z=xl'CloseWorkbook(1)
drop object xl
end

Hope this helps!!

Regards,

Rob Leighton

Ron Klassen

  • Member
  • **
  • Posts: 16
    • View Profile
Re: Excel Spreadsheet Column Options
« Reply #2 on: August 31, 2022, 01:15:33 PM »
Thanks Rob,

That's great.

Ron

Ron Klassen

  • Member
  • **
  • Posts: 16
    • View Profile
Re: Excel Spreadsheet Column Options
« Reply #3 on: August 31, 2022, 05:51:08 PM »
There's a lot of info under excel and excel'columns etc. Where would I find some documentation on this?

RobL

  • Silver Member
  • ***
  • Posts: 21
    • View Profile
Re: Excel Spreadsheet Column Options
« Reply #4 on: September 01, 2022, 12:40:01 PM »
Hi Ron,

I found useful information here: https://docs.microsoft.com/en-us/office/vba/api/overview/excel. I've also found examples here on the forum and the old mailing list as well as googling for examples of Excel VBA code and then trying to convert the solutions to PxPlus.

Rob