Closed SWAT10101 closed 10 months ago
This is a simplified code according to your sample, which works for me without problems. Check if Excel will issue an alert with it?
$headerStyle = [];
$rowStyle = ['text-align' => 'center', 'border' => 'thin'];
$excel = \avadim\FastExcelWriter\Excel::create(['DW', 'In Deal', 'Out OutBy', 'Country', 'Symbols']);
// DW Deals Sheet ---------------------------------------------------------
$sheet = $excel->getSheet('DW');
$sheet->setColWidth(['A', 'B', 'C', 'D', 'G', 'H', 'I'], 'auto');
$sheet->setFreeze(1);
$sheet->writeHeader(['Login', 'Amount', 'Time', 'Deal'], $headerStyle);
$sheet->setColFormat('A', '@integer'); //Login
$sheet->setColFormat('B', '[BLUE][$$]#,##0.00;[RED]-[$$]#,##0.00'); //Amount
$sheet->setColFormat('C', 'YYYY-MM-DD HH:MM:SS'); //Time
$sheet->setColFormat('D', '@integer'); //Deal
//(some query logic)
$areaTotal = $sheet->makeArea('G4:I7');
$areaData = $sheet->beginArea('A2');
$areaData->setValue('A2', 'Login', $rowStyle);
$areaData->setValue('B2', 'Profit', $rowStyle);
$areaData->setValue('C2', 'Time', $rowStyle);
$areaData->setValue('D2', 'Deal', $rowStyle);
//Prepare total section
$TotalDeposit = 111;
$TotalWithdrawal = 222;
$countDeposit = 333;
$countWithdrawal = 444;
$areaTotal->setValue('I4', 'Total Rows', $rowStyle)->applyFontStyleBold();
$areaTotal->setValue('G5', 'Total Deposit', $rowStyle)->applyFontColor('#3A00FF')->applyFontStyleBold();
$areaTotal->setValue('G6', 'Total Withdrawal', $rowStyle)->applyFontColor('#FF0000')->applyFontStyleBold();
$areaTotal->setValue('G7', 'Net', $rowStyle)->applyFontStyleBold();
$TotalStyle = ['format' => '[BLUE][$$]#,##0.00;[RED]-[$$]#,##0.00', 'text-align' => 'center', 'border' => 'thin', 'font' => ['style' => 'bold']];
$areaTotal->setValue('H5', $TotalDeposit, $TotalStyle);
$areaTotal->setValue('H6', $TotalWithdrawal, $TotalStyle);
$areaTotal->setValue('H7', $TotalDeposit + $TotalWithdrawal, ['format' => '[$$]#,##0.00', 'text-align' => 'center', 'border' => 'thin', 'font' => ['style' => 'bold']]);
$areaTotal->setValue('I5', $countDeposit, $rowStyle)->applyFontStyleBold();
$areaTotal->setValue('I6', $countWithdrawal, $rowStyle)->applyFontStyleBold();
$areaTotal->setValue('I7', $countDeposit + $countWithdrawal, ['format' => '#,##0', 'text-align' => 'center', 'border' => 'thin', 'font' => ['style' => 'bold']]);
//save file
I have tried the code with the same issue
What language is used in your Excel? Perhaps these problems are related to the locale that are used in your Excel. Try to set the locale to "en":
Excel::create(['DW', 'In Deal', 'Out OutBy', 'Country', 'Symbols']);
$excel->setLocale('en');
If that doesn't work, you can try deleting from this code the lines with formatting one by one until the error goes away.
@aVadim483 Thank you a lot for helping
The issue was in other sheets in code missing @
$sheet->setColFormat('C', 'string'); //Type
Hello,
I was using version 2.3 after updating to 4.2 when generating the Excel file and opening it using Microsoft Excel I got the below alert but nothing changes in style and contact, But when open the file using LibreOffice I did not face an alert Microsoft Excel Version 2307 Build 16.0.16626.20110
Do I do something wrong below is part of the code for one sheet