lua-users home
lua-l archive

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


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:

-----
require("luacom")
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)
end
row = 1

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

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*")
    else
ws.Cells(row+1, col).Value2 = "'" .. value:match("^.+%s*")
    end
  end
end
report_path = report_path:gsub("/", "\\")
fn_out = report_path .. filename
wb.SaveAs(report_path, fn_out)
wb = nil
xl:Quit()
xl = nil


-----

Any help or insight on this issue is greatly appreciated.

Kind regards,

Steffen


--

The best time to call me is e-mail.