How to embed an Excel object

zhaozj2021-02-16  43

When program development, sometimes you need to use the PowerBuilder to use the Excel application. If you retrieve the data, you will transfer the data into the Excel table in accordance with the format requirements. The implementation steps are as follows:

1. Create and connect the object:

OleObject LOO_EXCEL

oleObject loo_sheet

LOO_EXCEL = CREATE OLEOBJECT

LOO_EXCEL.CONNECTTONEWOBJECT ("Excel.Application")

// Set the default font and size

LOO_EXCEL.Application.standardFont = "Arial Narrow"

LOO_EXCEL.Application.standardFontSize = "8"

LOO_EXCEL.Application.Workbooks.add ()

LOO_SHEET = LOO_EXCEL.Application.WorkBooks (1) .Worksheets (1)

LOO_EXCEL.Application.visible = true

LOO_EXCEL.Application.screenupDating = false // Shielded Properties

2. Call the properties of the Excel itself, function, fill in the data to Excel through the data window:

LOO_EXCEL.Application.screenupDating = true // Setting visible properties

3. Disconnect and release the object: LOO_EXCEL.DISCONNECTOBJECT ()

// Note: It is recommended to reference the API function to capture the Handle.

Destroy LOO_EXCEL

转载请注明原文地址:https://www.9cbs.com/read-26081.html

New Post(0)