Learning & Integrating web technology and code help directory

How to use PHP & Add Cell Border in excel (Excel.Application)

2 comments
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.
Example
php_cell_borders.php
  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <?  
  7.   
  8. //*** Get Document Path ***//  
  9. $strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp  
  10.   
  11. $xlEdgeLeft = 7;  
  12. $xlEdgeTop = 8;  
  13. $xlEdgeBottom = 9;  
  14. $xlEdgeRight = 10;  
  15.   
  16. //*** Excel Document Root ***//  
  17. $strFileName = "MyXls/MyExcel.xls";  
  18.   
  19. //*** Connect to Excel.Application ***//  
  20. $xlApp = new COM("Excel.Application");  
  21. $xlBook = $xlApp->Workbooks->Add();  
  22. $xlSheet1 = $xlBook->Worksheets(1);  
  23. $xlApp->Application->Visible = False;  
  24.   
  25. //*** Sheet 1 ***//  
  26. $xlSheet1->Name = "My Sheet1";  
  27.   
  28. //*** Write text to Row 1 Column 1 ***//  
  29. $xlApp->ActiveSheet->Cells(1,1)->Value = "ShotDev.Com";  
  30.   
  31. //*** Write Cell Border ***//  
  32. $xlApp->ActiveSheet->Range("B3:D5")->BORDERS->Weight = 2;  
  33.   
  34. //*** Write Cell Border ***//  
  35. $xlApp->ActiveSheet->Range("B7:D9")->BORDERS($xlEdgeLeft)->Weight = 2;  
  36. $xlApp->ActiveSheet->Range("B7:D9")->BORDERS($xlEdgeTop)->Weight = 2;  
  37. $xlApp->ActiveSheet->Range("B7:D9")->BORDERS($xlEdgeBottom)->Weight = 2;  
  38. $xlApp->ActiveSheet->Range("B7:D9")->BORDERS($xlEdgeRight)->Weight = 2;  
  39.   
  40. @unlink($strFileName); //*** Delete old files ***//  
  41.   
  42. $xlBook->SaveAs($strPath."/".$strFileName); //*** Save to Path ***//  
  43.   
  44. //*** Close & Quit ***//  
  45. $xlApp->Application->Quit();  
  46. $xlApp = null;  
  47. $xlBook = null;  
  48. $xlSheet1 = null;  
  49. ?>  
  50. Excel Created <a href="<?=$strFileName?>">Click here</a> to Download.  
  51.   
  52. </body>  
  53. </html>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP & Add Cell Border in excel  (Excel.Application)

2 comments :


  1. Excel 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.

    ReplyDelete

  2. Excel 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.

    ReplyDelete