/**
  * @param XlsxSheet $sheet
  * @param array $dataArray
  * @param integer $startAtLine
  * @param string $startAtRow
  * @throws \Exception
  */
 public function appendDataArrayToSheet($sheet, $dataArray, $startAtLine, $startAtRow = 'A')
 {
     $anchor = '</sheetData>';
     $oldContent = $this->archiveHelper->getFromName($sheet->getPath());
     $newContent = '';
     $writtenLines = $startAtLine;
     foreach ($dataArray as $data) {
         $newContent .= XlsxRowTemplate::getTemplateString($data, $startAtRow, $writtenLines);
         $writtenLines++;
     }
     $newContent .= $anchor;
     if (substr_count($oldContent, $anchor) !== 1) {
         throw new \Exception('could not find anchor', 1452522446);
     }
     $newFileData = str_replace($anchor, $newContent, $oldContent);
     $this->archiveHelper->deleteName($sheet->getPath());
     $this->archiveHelper->addFromString($sheet->getPath(), $newFileData);
 }
<?php

require_once __DIR__ . '/../vendor/autoload.php';
$data = array(array(500, 999502, 22448, '01234'), array(501, 999501, 22448, '01234'));
$tempFile = __DIR__ . '/tempFile';
$startAtLine = 14;
$newContent = '';
foreach ($data as $item) {
    $newContent .= \MoveElevator\XlsxAppender\Templates\XlsxRowTemplate::getTemplateString($item, 'A', $startAtLine);
    $startAtLine++;
}
file_put_contents($tempFile, $newContent, FILE_APPEND);
$xlsxAppender = new \MoveElevator\XlsxAppender\XlsxAppender(__DIR__ . '/../tests/fixtures/test.xlsx');
$sheet = $xlsxAppender->getSheetPathBySheetName('sheet1');
$xlsxAppender->appendTempFileToSheet($tempFile, $sheet);
$xlsxAppender->saveAndExit();
 /**
  * @Revs(1000)
  */
 public function benchGetTemplateString()
 {
     XlsxRowTemplate::getTemplateString(array(1, "PHP", TRUE, 4, 5, "Bench", 7, FALSE, 9), 'A', 1);
 }