Example: Write UTF-8 Strings

An example of writing simple UTF-8 strings to a worksheet.

Unicode strings in Excel must be UTF-8 encoded. With xlsxwriter all that is required is that the source file is UTF-8 encoded and Lua will handle the UTF-8 strings like any other strings:

_images/utf8.png
----
--
-- A simple Unicode UTF-8 example using the xlsxwriter.lua module.
--
-- Note: The source file must be UTF-8 encoded.
--
-- Copyright 2014-2015, John McNamara, jmcnamara@cpan.org
--

local Workbook = require "xlsxwriter.workbook"

local workbook  = Workbook:new("utf8.xlsx")
local worksheet = workbook:add_worksheet()

worksheet:write("B3", "Это фраза на русском!")

workbook:close()