Zursion Insights
  • Informational
  • Gadgets
  • News
  • Security
  • Tools
No Result
View All Result
Zursion Insights
  • Informational
  • Gadgets
  • News
  • Security
  • Tools
No Result
View All Result
Zursion Logo
No Result
View All Result

How to Fill Background Color of Cells in PHPExcel

September 4, 2022
in Informational
Reading Time: 2 mins read
A A
Coding Banner

Coding Banner

Share on FacebookShare on TwitterShare on LinkedIn
ADVERTISEMENT

PHPExcel is a library written to aid in the development of PHP applications for reading and writing spreadsheet files – particularly Excel. At the very least, that’s what I know since PHPExcel as stated in its archived repository, is already DEAD. It is now succeeded by a new library which is the PhpSpreadsheet.

So for this info, I would just like to show you how to fill the background color of a cell in Excel using a code snippet which was fairly shared on Stackoverflow.

RelatedPosts

BPI Launches BEA Chat: A New 24/7 Banking Assistant

MMDA Launches ‘May Huli Ka’ Website for Contactless Traffic Violation Checks

ChatGPT Prompts Every Marketer Should Have on Hand

function cellColor($objPHPExcel, $cells, $color){​​​​​
    $objPHPExcel->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array(
        'type' => PHPExcel_Style_Fill::FILL_SOLID,
        'startcolor' => array(
             'rgb' => $color
        )
    ));
}​​​​​

Since I am using this inside a PHP Framework, this is just a bit different from the original answer provided on the link above but its entirety is a mimic of it.

With this function, the developer will just have to call the function and supply the library instance, targeted cells and colors in hexadecimal format as parameters to have it working.

ADVERTISEMENT

This could be used simply as such:

cellColor($objPHPExcel, 'A17:I17', 'F28A8C');

By doing so, this will produce the following output.

PHPExcel Change Cell Background
PHPExcel Change Cell Background

Surely you’d have everything set by now. If you have any questions, please don’t hesitate to drop your comments down below.

Tags: CodingPHPPHPExcel
ShareTweetShare
ADVERTISEMENT
Previous Post

Apple Security Flaw 2022 – Update your Apple Devices Now!

Next Post

ITEXMO Sending Message Response Code 20 and 21 Definition

Related Posts

Coding Banner

Equivalent of strtotime when using DateTime Class in PHP

September 17, 2022
ITEXMO Banner

ITEXMO Sending Message Response Code 20 and 21 Definition

September 10, 2022

Solution to Linux Tools (sh) not found warning – Git Extensions

August 18, 2022

Display details of info column in SHOW PROCESSLIST – MySQL

August 16, 2022
Next Post
ITEXMO Banner

ITEXMO Sending Message Response Code 20 and 21 Definition

Samsung Galax A22 Specs and Pricing

Samsung Galaxy A22 5G Specs in the Philippines

Discussion about this post

Signup and Get Informed

Recommended

Get 2 Hours of Free Social Media Access Daily with Smart!

Get 2 Hours of Free Social Media Access Daily with Smart!

November 13, 2024
Infinix HOT 40i

Infinix HOT 40i Specs and Price in the Philippines

December 25, 2023
GCash

How to Fix GCash Error Pertaining to Developer Options

October 23, 2023
Google Philippines' Security Tips

Google Philippines’ 8 Tips to Stay Safe and Secure While Browsing the Internet

February 13, 2024

Categories

  • Gadgets
  • Informational
  • News
  • Others
  • Security

Home Grown Tools

Unleash your inner powerhouse! Explore our curated tools to quickly accomplish tasks & elevate your designs.

Code faster, manage time like a pro, & achieve more. Check it at Zursion

Disclaimer

Insights, a cornerstone of Zursion, serves as our dedicated blog platform, providing a comprehensive hub for thought-provoking articles and engaging blog posts. Delving into a diverse array of topics, Insights offers valuable perspectives and insights that empower readers to navigate the complexities of the modern world.

  • Home
  • Tools
  • Contact
  • Privacy Policy

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • Informational
  • Gadgets
  • News
  • Security
  • Tools
This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.