You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example, I want to set a color to the entire rows that contains a text in second column. Likewise adding a BG color to the entire rows that contains a text in second column.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using laravel framework to export an excel. I'm using a manual procedure to set background colors to particular rows. Here's the sample excel data
Sample Excel data https://i.stack.imgur.com/4uV2j.png
In the above example, I want to set a color to the entire rows that contains a text in second column. Likewise adding a BG color to the entire rows that contains a text in second column.
Excel after setting the BG colors https://i.stack.imgur.com/UGghi.png
I've tried this manual adding
` use Illuminate\Support\Facades\App;
use Maatwebsite\Excel\Facades\Excel;
public function add_color_to_sheet($sheet) {
$sheet->cells('A1:E1', function ($cells) {
$cells->setBackground('#3490ED');
});
$sheet->cells('A2:E2', function ($cells) {
$cells->setBackground('#6D8947');
});
$sheet->cells('A3:E3', function ($cells) {
$cells->setBackground('#0DF3FE');
});
$sheet->cells('A8:E8', function ($cells) {
$cells->setBackground('#0DF3FE');
});
$sheet->cells('A11:E11', function ($cells) {
$cells->setBackground('#6D8947');
});
$sheet->cells('A12:E12', function ($cells) {
$cells->setBackground('#0DF3FE');
});
$sheet->cells('A14:E14', function ($cells) {
$cells->setBackground('#0DF3FE');
});
};`
How can I do it dynamically by using conditions to set the background colors?
Beta Was this translation helpful? Give feedback.
All reactions