Fixed more rows when reporting to Excel Reports. Greater then 65535 rows.
[fa-stable.git] / reporting / includes / excel_report.inc
index c6f0d4436039b97519644a57e94f08c915baae3d..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
 {
@@ -86,7 +87,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                $this->Spreadsheet_Excel_Writer_Workbook($this->path."/".$this->unique_name);
                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)
@@ -641,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()