You are here

private function PHPExcel_Writer_Excel5_Workbook::_writeNames in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Workbook.php \PHPExcel_Writer_Excel5_Workbook::_writeNames()

* Write the NAME record to define the print area and the repeat rows and cols.

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Workbook.php, line 558

Class

PHPExcel_Writer_Excel5_Workbook
PHPExcel_Writer_Excel5_Workbook

Code

private function _writeNames() {

  // total number of sheets
  $total_worksheets = $this->_phpExcel
    ->getSheetCount();

  // Create the print area NAME records
  for ($i = 0; $i < $total_worksheets; ++$i) {
    $sheetSetup = $this->_phpExcel
      ->getSheet($i)
      ->getPageSetup();

    // Write a Name record if the print area has been defined
    if ($sheetSetup
      ->isPrintAreaSet()) {

      // Print area
      $printArea = PHPExcel_Cell::splitRange($sheetSetup
        ->getPrintArea());
      $printArea = $printArea[0];
      $printArea[0] = PHPExcel_Cell::coordinateFromString($printArea[0]);
      $printArea[1] = PHPExcel_Cell::coordinateFromString($printArea[1]);
      $print_rowmin = $printArea[0][1] - 1;
      $print_rowmax = $printArea[1][1] - 1;
      $print_colmin = PHPExcel_Cell::columnIndexFromString($printArea[0][0]) - 1;
      $print_colmax = PHPExcel_Cell::columnIndexFromString($printArea[1][0]) - 1;
      $this
        ->_writeNameShort($i, 0x6, $print_rowmin, $print_rowmax, $print_colmin, $print_colmax);
    }
  }

  // Create the print title NAME records
  for ($i = 0; $i < $total_worksheets; ++$i) {
    $sheetSetup = $this->_phpExcel
      ->getSheet($i)
      ->getPageSetup();

    // simultaneous repeatColumns repeatRows
    if ($sheetSetup
      ->isColumnsToRepeatAtLeftSet() && $sheetSetup
      ->isRowsToRepeatAtTopSet()) {
      $repeat = $sheetSetup
        ->getColumnsToRepeatAtLeft();
      $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1;
      $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1;
      $repeat = $sheetSetup
        ->getRowsToRepeatAtTop();
      $rowmin = $repeat[0] - 1;
      $rowmax = $repeat[1] - 1;
      $this
        ->_writeNameLong($i, 0x7, $rowmin, $rowmax, $colmin, $colmax);

      // (exclusive) either repeatColumns or repeatRows
    }
    else {
      if ($sheetSetup
        ->isColumnsToRepeatAtLeftSet() || $sheetSetup
        ->isRowsToRepeatAtTopSet()) {

        // Columns to repeat
        if ($sheetSetup
          ->isColumnsToRepeatAtLeftSet()) {
          $repeat = $sheetSetup
            ->getColumnsToRepeatAtLeft();
          $colmin = PHPExcel_Cell::columnIndexFromString($repeat[0]) - 1;
          $colmax = PHPExcel_Cell::columnIndexFromString($repeat[1]) - 1;
        }
        else {
          $colmin = 0;
          $colmax = 255;
        }

        // Rows to repeat
        if ($sheetSetup
          ->isRowsToRepeatAtTopSet()) {
          $repeat = $sheetSetup
            ->getRowsToRepeatAtTop();
          $rowmin = $repeat[0] - 1;
          $rowmax = $repeat[1] - 1;
        }
        else {
          $rowmin = 0;
          $rowmax = 65535;
        }
        $this
          ->_writeNameShort($i, 0x7, $rowmin, $rowmax, $colmin, $colmax);
      }
    }
  }
}