Change language

PHP Spreadsheet_Excel_Writer | AddFormat () Function

Syntax:
Workbook::& amp; addFormat ($properties = array())
Parameters:This the function takes one parameter, $properties, which takes the value of an array. To set the different formats, we use their respective functions, such as setBold() for Bold, setBorder() for borders, and many more.Example 1: require_once ’ Spreadsheet / Excel / Writer.php’ ;  
// Add book $workbook = new Spreadsheet_Excel_Writer();  
// Add format to spreadsheet $format_bold = & amp; $workbook -> addFormat();  
// Set format to bold $format_bold -> setBold();  
// Add worksheet to Sprerdsheet $worksheet = & amp; $workbook -> addWorksheet(); $format_bold -> setBorder (2);  
// Save to sheet $worksheet -> write (0, 0, "Details of GeeksforGeeks Contributors ", $format_bold ); $worksheet -> write (1, 0, "Author" , $format_bold ); $worksheet -> write (1, 1, "User Handle" , $format_bold ); $worksheet -> write (2, 0, "Sarthak" ); $worksheet -> write (2, 1, "sarthak_ishu11" );  
// Submit the .xlsx file in the header $workbook -> send ( ’test.xls’ );  
// Close the book object $workbook -> close(); ?>
Output: Example 2: < tbody> require_once ’Spreadsheet / Excel / Writer.php’ ;  
// Add book $workbook = new Spreadsheet_Excel_Writer();  
// Add format to spreadsheet $format_border = & amp; $workbook -> addFormat();  
// Add worksheet to Sprerdsheet $worksheet = & amp; $workbook -> addWorksheet();  
// Set and add border width $format_border -> setBorder (2);  
// Set and add color to border $format_border -> setBorderColor ( ’red’ );  
// Save to sheet $worksheet -> write (0, 0, "Details of GeeksforGeeks Contributors ", $format_bold ); $worksheet -> write (1, 0, "Author" , $format_border ); $worksheet -> write (1, 1, "User Handle" , $format_border ); $worksheet -> write (2, 0, "Sarthak" ); $worksheet -> write (2, 1, "sarthak_ishu11" );  
// Submit the .xlsx file in the header $workbook -> send ( ’test.xls’ );  
// Close the book object $workbook -> close(); ?>
Output: Link : https://pear.php.net/manual /en/package.fileformats.spreadsheet-excel-writer.intro-format.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically