Skip to content

Commit

Permalink
Merge pull request #42 from JurajG007/patch-1
Browse files Browse the repository at this point in the history
Update HtmlPhpExcel.php
  • Loading branch information
sprain authored Feb 23, 2024
2 parents 567fa60 + beee49e commit 1679a93
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
34 changes: 34 additions & 0 deletions example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,37 @@
</tr>

</table>
<table _excel-name="Named Sheet A" >
<tr>
<td>1.</td>
<td _excel-styles='{"width": "auto"}'>Sheet A - text value 1</td>
<td><strong>111</strong></td>
</tr>
<tr>
<td>2.</td>
<td _excel-styles='{"width": "auto"}'>Sheet A - text value 2</td>
<td><strong>222</strong></td>
</tr>
<tr>
<td>3.</td>
<td _excel-styles='{"width": "auto"}'>Sheet A - text value 2</td>
<td><strong>333</strong></td>
</tr>
</table>
<table _excel-name="Named Sheet B" >
<tr>
<td>1.</td>
<td _excel-styles='{"width": "auto"}'>Sheet B - text value 1</td>
<td><strong>111</strong></td>
</tr>
<tr>
<td>2.</td>
<td _excel-styles='{"width": "auto"}'>Sheet B - text value 2</td>
<td><strong>222</strong></td>
</tr>
<tr>
<td>3.</td>
<td _excel-styles='{"width": "auto"}'>Sheet B - text value 3</td>
<td><strong>333</strong></td>
</tr>
</table>
6 changes: 4 additions & 2 deletions lib/HtmlPhpExcel/HtmlPhpExcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@ private function parseHtml(): void

private function createExcel(): void
{
// Remove 1st sheet created automatically with new excel
$this->excel->removeSheet(1);

// Loop over all tables in document
foreach($this->document->getTables() as $table) {

// Handle worksheets
$this->excel->makeSheet($table->getAttribute('_excel-name'));
$sheet = $this->excel->sheet();
$sheet = $this->excel->makeSheet($table->getAttribute('_excel-name'));

// Loop over all rows
$rowIndex = 1;
Expand Down

0 comments on commit 1679a93

Please sign in to comment.