export excel second

This commit is contained in:
Roshan 2024-09-30 17:25:58 +05:45
parent 4683fe67a7
commit ec6bfaf7ff
3 changed files with 46 additions and 11 deletions

View File

@ -692,7 +692,7 @@ class bibaccounts
{
if (!isset($ReportOptions['AmountColWidth'])) $ReportOptions['AmountColWidth'] = 180;
?>
<table class="table table-sm table-accounts">
<table id='myTable'class="table table-sm table-accounts">
<?php if ($displayHeadings) { ?>
<thead>
<tr>

View File

@ -17,7 +17,7 @@ $PL = $IncomesTotal - $ExpensesTotal;
<h5 class="m-0"><?php echo $pageTitle; ?> </h5>
</div>
<div class="card-body">
<table class="table table-bordered table-hover">
<table id='myTable'class="table table-bordered table-hover">
<thead>
<tr>
<th colspan="4">Profit & Loss Statement</th>
@ -95,7 +95,7 @@ $PL = $IncomesTotal - $ExpensesTotal;
{
$total = 0;
?>
<table class="table table-bordered table-hover">
<table id='myTable' class="table table-bordered table-hover">
<thead>
<tr>
<th>Account</th>
@ -121,6 +121,41 @@ $PL = $IncomesTotal - $ExpensesTotal;
</tr>
</tfoot> -->
</table>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php
}

View File

@ -229,7 +229,7 @@ $BIBAccounts = new BIBAccounts();
?>
<div class="col-6 p-0">
<div class="table-responsive">
<table id='myTable' class="table ">
<table id='myTable' class="table">
<thead>
<tr>
<th class="group-name pl-1">Particulars</th>
@ -250,10 +250,10 @@ $BIBAccounts = new BIBAccounts();
<?php foreach ($AccountGroups as $group) : ?>
<tr>
<td colspan="2" class="p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<!-- <div id="group_<?php echo $group->acgroup_id; ?>" class=""> -->
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</div>
<!-- </div> -->
</td>
</tr>
@ -275,15 +275,15 @@ $BIBAccounts = new BIBAccounts();
<tfoot>
<?php $PL = $incomes_totalClosingCr - $incomes_totalClosingDr; ?>
<tr>
<th class="p-1">Total Incomes</th>
<th class="cr closing-cr text-bold">
<td class="p-1">Total Incomes</th>
<td class="cr closing-cr text-bold">
<?php if ($PL > 0) : ?>
<?php echo myCurrency($incomes_totalClosingCr); ?>
<?php else : ?>
<?php echo myCurrency($incomes_totalClosingCr + abs($PL)); ?>
<?php endif; ?>
</th>
</tr>
</tfoot>
</table>
@ -312,11 +312,11 @@ $BIBAccounts = new BIBAccounts();
<?php foreach ($AccountGroups as $group) : ?>
<tr>
<td colspan="2" class="p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<!-- <div id="group_<?php echo $group->acgroup_id; ?>" class=""> -->
<i> <?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</i>
</div>
<!-- </div> -->
</td>
</tr>
<?php