PB6, Excel OLE and non-English characters
Posted on 2003-03-21
Life was easy when I used to fill my Excel worksheet only with English characters, like Sheet.Cells[1,1].Value="string value". But things changed when I tried to transfer some Russian characters (cp1251) from PB to Excel. Excel's cell looks like I don't have Russian font - letters with accents, etc - like international ASCII 128+ characters. My next step was to discover how Excel stores Russian strings in its cells. I tried to read cell's value from Excel and got totally unreadable crap with "undefined character" boxes. Furthermore, when I tried to transfer one Russian (1,1) value to another (3,3) (through PB), using Sheet.Cells[3,3].Value = Sheet.Cells[1,1].Value - I got another unreadable crap in Excel's cell 3,3 ! Value for (1,1) was, say, "test(eng)+test(rus)" and in (3,3) I got "test(eng)+crap(unknown)".
This stuff drives me insane. Some non-PB people gave me a clue to use win32api function called OemToAnsi in order to convert my strings to some form of Unicode or something. I declared this function like FUNCTION boolean OemToAnsi ( ref string src, ref string dst ) Library "USER32". During test run ...
str1 = "A"
str2 = "B"
res = OemToAnsi( str1, str2 )
... application crashes with "Error calling external function OemToAnsi". I don't have so-called PowerBuilder-for-Unicode-edition, so I don't have any useful ideas about how to transfer my Russian strings from PB to Excel.
Please help, I'm giving all points that I've got.