Fixed more rows when reporting to Excel Reports. Greater then 65535 rows.
[fa-stable.git] / reporting / includes / excel_report.inc
index f139ba836465caa053f39ee787d1316b95341c25..3786a91aaf9d92bcba4522a2096473deac9dc390 100644 (file)
@@ -13,6 +13,7 @@ include_once($path_to_root . "/reporting/includes/Workbook.php");
 include_once($path_to_root . "/admin/db/company_db.inc");
 include_once($path_to_root . "/admin/db/fiscalyears_db.inc");
 include_once($path_to_root . "/config.php");
+define('MAX_ROW_SHEET', 65530);
 // xls version
 class FrontReport extends Spreadsheet_Excel_Writer_Workbook
 {
@@ -81,13 +82,12 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                $rtl = ($_SESSION['language']->dir == 'rtl');
                $this->code = strtolower($_SESSION['language']->encoding);
                $this->filename = $filename.".xls";
-               $this->unique_name = uniqid('').".xls";
+               $this->unique_name = random_id().".xls";
                $this->path = company_path(). '/pdf_files';
                $this->Spreadsheet_Excel_Writer_Workbook($this->path."/".$this->unique_name);
-               //$this->setCountry(48);
                if ($this->code != "iso-8859-1")
                        $this->setVersion(8); // set biff version to 8 (0x0006 internal)
-               $this->sheet =& $this->addWorksheet($this->worksheetNameGenerator($this->title));
+               $this->sheet = $this->addWorksheet($this->worksheetNameGenerator($this->title));
                if ($this->code != "iso-8859-1")
                        $this->sheet->setInputEncoding($this->code); // set sheet encoding
                if ($rtl)
@@ -198,10 +198,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
        {
                if (!isset($this->formatAmount[$dec]))
                {
-                       //global $thoseps,$decseps;
                        $dec = (int)$dec;
-                       //$tsep = $thoseps[user_tho_sep()];
-                       //$dsep = $decseps[user_dec_sep()];
                        $tsep = ',';
                        $dsep = '.';
                        $format = "###{$tsep}###{$tsep}###{$tsep}##0";
@@ -645,6 +642,17 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
        function NewLine($l=1, $np=0, $h=NULL)
        {
                $this->y += $l;
+               if ($this->y > MAX_ROW_SHEET)
+               {
+                       $this->y = 0;
+                       $this->sheet = $this->addWorksheet();
+                       if ($this->code != "iso-8859-1")
+                               $this->sheet->setInputEncoding($this->code); // set sheet encoding
+                       if ($_SESSION['language']->dir == 'rtl')
+                               $this->sheet->setRTL();
+                       for ($i = 0; $i < $this->numcols; $i++)
+                               $this->sheet->setColumn($i, $i, $this->px2units($this->cols[$i + 1] - $this->cols[$i]));
+               }
        }
        
        function NewPage()