How to use PHP & Add Cell Border in excel (Excel.Application)
How to use PHP & Add Cell Border in excel (Excel.Application) The Learn / tutorial php programming how to using PHP Add Cell Border in excel
ShotDev Focus:
- PHP & Add Cell Border in excel.
- PHP & Add Cell Border in excel.
Example
php_cell_borders.php
- <html>
- <head>
- <title>ShotDev.Com Tutorial</title>
- </head>
- <body>
- <?
- //*** Get Document Path ***//
- $strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
- $xlEdgeLeft = 7;
- $xlEdgeTop = 8;
- $xlEdgeBottom = 9;
- $xlEdgeRight = 10;
- //*** Excel Document Root ***//
- $strFileName = "MyXls/MyExcel.xls";
- //*** Connect to Excel.Application ***//
- $xlApp = new COM("Excel.Application");
- $xlBook = $xlApp->Workbooks->Add();
- $xlSheet1 = $xlBook->Worksheets(1);
- $xlApp->Application->Visible = False;
- //*** Sheet 1 ***//
- $xlSheet1->Name = "My Sheet1";
- //*** Write text to Row 1 Column 1 ***//
- $xlApp->ActiveSheet->Cells(1,1)->Value = "ShotDev.Com";
- //*** Write Cell Border ***//
- $xlApp->ActiveSheet->Range("B3:D5")->BORDERS->Weight = 2;
- //*** Write Cell Border ***//
- $xlApp->ActiveSheet->Range("B7:D9")->BORDERS($xlEdgeLeft)->Weight = 2;
- $xlApp->ActiveSheet->Range("B7:D9")->BORDERS($xlEdgeTop)->Weight = 2;
- $xlApp->ActiveSheet->Range("B7:D9")->BORDERS($xlEdgeBottom)->Weight = 2;
- $xlApp->ActiveSheet->Range("B7:D9")->BORDERS($xlEdgeRight)->Weight = 2;
- @unlink($strFileName); //*** Delete old files ***//
- $xlBook->SaveAs($strPath."/".$strFileName); //*** Save to Path ***//
- //*** Close & Quit ***//
- $xlApp->Application->Quit();
- $xlApp = null;
- $xlBook = null;
- $xlSheet1 = null;
- ?>
- Excel Created <a href="<?=$strFileName?>">Click here</a> to Download.
- </body>
- </html>
Create a php file and save to path root-path/myphp/
Screenshot
Subscribe to:
Post Comments
(
Atom
)
ReplyDeleteExcel is a software program from Microsoft basic excel for beginners that is a part of Microsoft Office. Excel calculations is compiled for making and altering spreadsheets that are spared with a .xls expansion. It's general uses in corporate cell-based figuring, turn tables, and different diagramming devices. With an Excel spreadsheet, you could make a month to month spending plan, track costs of doing business, or sort and compose a lot of information calculations in spreadsheets of Excels.
ReplyDeleteExcel is a software program from Microsoft basic excel for beginners that is a part of Microsoft Office. Excel calculations is compiled for making and altering spreadsheets that are spared with a .xls expansion. It's general uses in corporate cell-based figuring, turn tables, and different diagramming devices. With an Excel spreadsheet, you could make a month to month spending plan, track costs of doing business, or sort and compose a lot of information calculations in spreadsheets of Excels.