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

Juan Jose Marquez Martin Accepted Answer Pending Moderation
  1. Wednesday, 30 October 2024 12:55 PM UTC
  2. PowerBuilder
  3. # 1
This code doesn't work:

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

in my version, with the classical GUI, not .NET



and into the help documentation says

ImportFile method (DataWindows)

method (DataWindows)

Description

Inserts data into a DataWindow control or DataStore from a file. The data can be tab-separated text, comma-separated text, XML, or dBase format 2 or 3.


When I try to import with XLSX!, <<fileXLSXName>> I receive the error code -3 -> Invalid argument

This works properly in another version?

Any idea for do it this without export to CSV and import after...?
 
 
 
Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 11 January 2018 17:08 PM UTC
  2. PowerBuilder
  3. # 2

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

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

 

Comment
  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
  1. Juan Jose Marquez Martin
  2. Wednesday, 30 October 2024 12:56 PM UTC
This code doesn't work:



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



in my version, with the classical GUI, not .NET







and into the help documentation says



ImportFile method (DataWindows)

method (DataWindows)

Description



Inserts data into a DataWindow control or DataStore from a file. The data can be tab-separated text, comma-separated text, XML, or dBase format 2 or 3.





When I try to import with XLSX!, <<fileXLSXName>> I receive the error code -3 -> Invalid argument



This works properly in another version?



Any idea for do it this without export to CSV and import after...?

  1. Helpful
  1. John Fauss
  2. Wednesday, 30 October 2024 13:19 PM UTC
The PB 2022 R3 Help topic for "ImportFile method (DataWindows)" lists the supported importtype argument values as: Text!, CSV!, XML!, DBase2! and DBase3! -- XLSX! is not a supported import type for this method.
  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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.