1. Jon Stoller
  2. PowerBuilder
  3. Thursday, 11 January 2018 16:38 PM UTC

Is there a way to import data from an Excel file into a datawindow through the powerscript code in a window object?

I want to have the user click on a command button, then in the powerscript code the data would be imported into the datawindow.

My application is set up meaning that I already have a datawindow that the columns match the columns in the excel file I want to import from. The excel file will be an xlsx or an xls type file. I can import the data successfully if I go through the Import-Export wizard. However, I don't want the user to have to use the wizard.

Preferably I would like the user to click on the command button and the data will automatically load into the datawindow. If anybody can give me an idea of what to do I would appreciate it.

If I could get an example of what to do, that would be great. Or, if there is a place in the documentation where I can see an example of how to do this, that would be good too.

Thank you in advance

Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 11 January 2018 17:08 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Use dw.ImportFile to import from Excel file into a DataWindow. Same for a DataStore.

dw_MyData.ImportFile(XLSX!, "myData.XLSX")

 

Comment
  1. Jon Stoller
  2. Friday, 12 January 2018 21:08 PM UTC
I will try



Thanks

  1. Helpful
  1. Ashutosh Varshney
  2. Friday, 12 January 2018 22:22 PM UTC
You can also use ole automation to open the xlsx file, save it as csv and then import the csv using ImportFile function. That way you would not have to worry about the ODBC being setup.



HTH.

  1. Helpful
  1. Heiko Bergner
  2. Monday, 15 January 2018 13:51 PM UTC
If you work with ole you could also open the excel-file, mark the data which should be imported, copy it to the clipboard

and then with



dw_1.importclipboard()



you can import the data into your datawindow.



Heiko



 

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.