B
B
bigazzzz2011-04-13 16:55:33
PHP
bigazzzz, 2011-04-13 16:55:33

SpreadSheet_Excel_Writer and tabs (sheets) with Russian names

The task was extremely simple. Generate an Excel file based on the data from the table. In principle, nothing is difficult. The PEAR module SpreadSheet_Excel_Writer was taken and tested and launched. And at the end of the work it turned out that in no way can I create a tab (new sheet) with a name in Russian. Thus, the "New Leaf" will be displayed in krakozyabry, and "Hello, world!" it will be quite comfortable to live on a sheet. The second day in a row I'm picking. And now, in fact, the question: Has anyone faced such a task? Were you able to implement it? If yes, what library did you use? Or maybe you managed to cure SpreadSheet_Excel_Writer?
<?php
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer("result.xls");
$workbook->setVersion(8);
$worksheet =& $workbook->addWorksheet("Новый лист1");
$worksheet->setInputEncoding('utf-8');
$worksheet->write(0,0,"Привет, мир!");
$workbook->close();
?>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
shurshur, 2011-04-13
@shurshur

PHPExcel would be better.

J
Jazzist, 2011-04-18
@Jazzist

Similarly, the names of the tabs in Russian are not obtained, although in the table itself - no problem.

K
Kirill Dlussky, 2011-05-03
@Dlussky

setInputEncoding is called after the sheet has been created and only affects its content. To name the worksheet, force iconv to be called at 1251
$worksheet =& $workbook->addWorksheet(iconv("UTF-8", "CP1251", "Hi worksheet");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question