1. Ashok Pattanaik
  2. PowerBuilder
  3. Monday, 3 February 2020 16:23 PM UTC

Hello Team,

I am using PowerBuilder 2017 R3 version. As per the business requirement in my project, data will load from excel and display it in screen. But I am finding problem to read data from each sheet around 5-sheets in the same excel file.

 

Can you please help me how to read data from each sheet in the same excel file?

excel.workbooks.open(ls_currDirPath)
 excel.application.visible = false
 excel.windowstate = 2

 excel.Range("A1:A49").Select
 excel.ActiveCell.CurrentRegion.Select()
  excel.Range("B1:B49").Select
 excel.ActiveCell.CurrentRegion.Select()
 ClipBoard('')
 excel.Selection.Copy()

 

Thanks and Regards,

Ashok Kumar Pattanaik

Luiz Ribeiro Accepted Answer Pending Moderation
  1. Tuesday, 4 February 2020 17:41 PM UTC
  2. PowerBuilder
  3. # 1

Hi.

 

Try to select the sheet before the first "range" command:

 

// aa_sheet = sheet name or Id

excel.Application.ActiveWorkBook.Worksheets(aa_sheet).Activate

 

Regards,

 

Luiz

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Tuesday, 4 February 2020 12:09 PM UTC
  2. PowerBuilder
  3. # 2
  • Excel contains a Workbooks collection = list of Workbook object
  • Each Workbook object contains a Sheets collection = list of "sheet" object
  • Each object in a Sheets collection is either a Worksheet object or a Chart object

You are looking for data in each each Worksheet object in the Sheets collection in the specific Workbook object you just opened.

Great documentation for Excel's object model.

HTH /Michael

Comment
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.