lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hi Steffen,

I think you may need to set the codepage in Windows. It could also be that the encodings don't match up. From what you write, it sounds like you are getting 8 bit chars from the DB (everything >127 becomes just '?'). Maybe those need to get converted to utf-8, or something else?


On Apr 23, 2015 11:05 AM, "Steffen Langenbach" <> wrote:
Good afternoon,

i'm facing some issues with a LuaCOM Script under Windows 7 (32bit) / Office 2010 / Lua 5.1 and the latest LuaCOM.
I create an Excel File from LuaCOM to store the result of an ODBC Query. But when i open the Excel File afterwards, all special characters are displayed incorrect.
All extended ASCII Characters are affected (> 127), and are stored in Excel with ASCII Character '63'.
When i route the output of the ODBC Query to a text file, it's ok, so i suspect it might be a problem with either LuaCOM.

Here's the script i use to write the data from a Lua table to the Excel sheet:

xl = luacom.GetObject("Excel.Apploexoexcelication")
if xl == nil then xl = luacom.CreateObject("Excel.Application") end
if xl then
  xl.Visible = false;
  wb = xl.Workbooks:Add()
  ws = wb.Worksheets(1)
row = 1

for col, value in pairs(t_cnames) do
  ws.Cells(row, col).Value2 = value

for row, t_row in pairs(t_result) do
  for col, value in pairs(t_row) do
    if t_ctypes[col] == number then
ws.Cells(row+1, col).Value2 = value:match("^.+%s*")
ws.Cells(row+1, col).Value2 = "'" .. value:match("^.+%s*")
report_path = report_path:gsub("/", "\\")
fn_out = report_path .. filename
wb.SaveAs(report_path, fn_out)
wb = nil
xl = nil


Any help or insight on this issue is greatly appreciated.

Kind regards,



The best time to call me is e-mail.