YJ Chen
YJ Chen

Reputation: 119

How to set the WrapText in the cells of Excel by PowerBuilder?

We now use PowerBuilder 11.5 to save a dataobject as an Excel file. One of the columns in the dataobject is the purchasing logs of the client in the recent years and each log should be showed in a line. But using the SaveAs function, I find no means to wrap the text. I tried to output '~r~n', '
', '\r\n' but none works. I also try to use the method of OLEObject. However, this method cannot work on the PCs without Excel so my supervisor suggest me not to use this method. Is there any method to wrap the text in a cell of Excel?

Upvotes: 2

Views: 873

Answers (1)

Terry
Terry

Reputation: 6225

If you use FileOpen()/FileWrite() etc... functions to build your own CSV file, you can do this. This following example shows how.

To build a single row with the second cell containing b on one line and c on the next line within that second cell, the CSV file looks like this:

a,"b
c",d

Now, this achieves the "stated" goal, but there's one catch I noticed: Excel doesn't, in PB parlance, AutoSizeHeight the row when the user imports the CSV. I have no idea how to solve this without OLE, but then you end up with the Excel dependency. Maybe someone else can come up with solution that solves this.

Good luck,

Terry.

Upvotes: 1

Related Questions