function f_in_xls($str)
{
$str = trim(pl_win2utf8($str));
return $str;
}
function parse_xls($filename)
{
$xls = new Spreadsheet_Excel_Reader();
$xls->setOutputEncoding('cp1250');
$xls->read($filename);
//lid
if (!isset($xls->sheets[1]['cells'][1][1])) {
$xls->sheets[1]['cells'][1][1] = '';
}
//podrubryka
if (!isset($xls->sheets[0]['cells'][7][2])) {
$xls->sheets[0]['cells'][7][2] = '';
}
//imię pierwszego autora
if (!isset($xls->sheets[0]['cells'][8][2])) {
$xls->sheets[0]['cells'][8][2] = '-';
}
//nazwisko pierwszego autora
if (!isset($xls->sheets[0]['cells'][8][3])) {
$xls->sheets[0]['cells'][8][3] = '-';
}
$w = array();
$w['rocznik'] = f_in_xls($xls->sheets[0]['cells'][1][2]);
$w['numer'] = f_in_xls($xls->sheets[0]['cells'][2][2]);
$w['odstrony'] = f_in_xls($xls->sheets[0]['cells'][3][2]);
$w['dostrony'] = f_in_xls($xls->sheets[0]['cells'][4][2]);
$w['tytul'] = f_in_xls($xls->sheets[0]['cells'][5][2]);
$w['lid'] = f_in_xls($xls->sheets[1]['cells'][1][1]);
$w['rubryka'] = f_in_xls($xls->sheets[0]['cells'][6][2]);
$w['podrubryka'] = f_in_xls($xls->sheets[0]['cells'][7][2]);
$autorzy = array();
$i = 0;
while(
isset($xls->sheets[0]['cells'][8 + $i][2]) &&
isset($xls->sheets[0]['cells'][8 + $i][3]) &&
trim($xls->sheets[0]['cells'][8 + $i][2]) &&
trim($xls->sheets[0]['cells'][8 + $i][3])
) {
$autorzy[$i]['imie'] = f_in_xls($xls->sheets[0]['cells'][8 + $i][2]);
$autorzy[$i]['nazwisko'] = f_in_xls($xls->sheets[0]['cells'][8 + $i][3]);
$i++;
}
$w['autorzy'] = $autorzy;
return $w;
}