I have an excel report which need to be locked from viewing without password authentication. I have tried with following snippets but it's only making it write protect. following is the code snippets I used.
$phpExcelObject->getSecurity()->setLockWindows(true);
$phpExcelObject->getSecurity()->setLockStructure(true);
$phpExcelObject->getSecurity()->setWorkbookPassword("password");
I am using PHPExcel version 1.8.
Seems like this is a know issue with PHPExcel
https://github.com/PHPOffice/PHPExcel/issues/442
Is there any alternative library for this which I can use to make my report password protected?
Thanks.
This isn't an option that PHPExcel supports. If you want to lock a file for reading, then you're very limited in your alternatives. The only libraries that I'm aware of capable of preventing read access to a file without a password are PHP's COM extension, which requires a COM enabled spreadsheet program such as MS Excel or OpenOffice Calc running on the server; the Open Office alternative to COM (PUNO), which requires Open Office installed on the server with Java support enabled; and Ilia Alshanetsky's Excel extension from github, that requires the commercial libXL component installed on your server.
Related
I have heard of PHP Excel inorder to work with excel documents in PHP. However do I require MS Office on the Ubuntu System inorder to work and serve excel documents? Or can the PHP Excel extension work ad hoc with serving excel documents in any system?
PHPExcel is pure PHP, it has no requirement to access MS Office in any way
From the readme of the PHPExcel repo on github
PHPExcel is a library written in pure PHP and providing a set of classes that allow you to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, Libre/OpenOffice Calc .ods, Gnumeric, PDF, HTML, ... This project is built around Microsoft's OpenXML standard and PHP.
Requirements
PHP version 5.2.0 or higher
PHP extension php_zip enabled (required if you need PHPExcel to handle .xlsx .ods or .gnumeric files)
PHP extension php_xml enabled
PHP extension php_gd2 enabled (optional, but required for exact column width autocalculation)
I am trying to edit my existing .xls Excel file. But i can't find the proper way to edit existing .xls excel file.
I had used PHPEXCEL for reading the .xls file and then writing the .xls file. But in that I lost some excel functionality like 'macro', 'vb form' from existing .xls file.
In my case, I need to update my Excel file day by day. So currently I am using PHPEXCEL, first I need to read Excel then write it with a new record.
So I am finding the way to edit existing .xls file with my new record.
Please share your idea if you find.
If you need support for macros and forms, then you're pretty limited in your choices. There's only 3 options available:
Ilia Alshanetsky's Excel extension now on github (requires commercial libXL component)
PHP's COM extension (requires a COM enabled spreadsheet program such as MS Excel or OpenOffice Calc running on the server)
The Open Office alternative to COM (PUNO) (requires Open/Libre Office installed on the server with Java support enabled)
When I use PHPExcel on a new server,
I faced the error "Class 'ZipArchive' not found" and it seems to be blocked by my hosting service provider.
Can't I use PHPExcel on the server without Zip support?
PHP 5.2.8 is installed on this server but I can't use a basic PHP source code for PHPExcel.
Any help will be appreciated,
thanks.
Certain spreadsheet file formats, such as OfficeOpenXML used as the default format by Excel 2007 and above, require ZipArchive. In most recent versions of PHP, ZipArchive is always available, but prior to PHP 5.3 it needed to be manually installed on some systems as a PHP extension.
If you don't have ZipArchive installed/enabled for your PHP, and can't enable it yourself, then you can use
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
PCLZip is included in the PHPExcel distribution as an alternative to PHP's built-in ZipArchive class, though it is quite a bit slower. Enabling PCLZip allows you to work with zip-based spreadsheet formats even without ZipArchive.
However, when we first bundled PCLZip (originally in PHPExcel 1.7.6), it was only an option when writing zip-based formats, not when reading them. We changed that in PHPExcel 1.8.0, so enabling PCLZip now allows you to read zip-based formats as well as writing them.
The PHPEXcel Reader documentation details the different spreadsheet formats, and explains which ones are zip-based.
PHPEXcel Reader documentation
My setup: IIS 7.5, PHP 5.4, Windows 7
I've trying to create a COM Object through PHP but I continue to get access denied. I've also followed a handful of tutorials on how to "grant access" to the ISUR to create the object but to no avail. I read the installation portion relevant to COM interfacing that says:
As of PHP 5.3.15 / 5.4.5, this extension requires php_com_dotnet.dll
to be enabled inside of php.ini in order to use these functions.
Previous versions of PHP enabled these extensions by default.
You are responsible for installing support for the various COM objects
that you intend to use (such as MS Word); we don't and can't bundle
all of those with PHP.
I've enabled the php_com_dotnet.dll file within the ini file but I still can't seem to create the COM object for Excel. Then if you read the second paragraph it says that you have to install support for the various COM objects you intend to use but doesn't specify how to go about doing that.
Question: How do I install support for the MS Excel COM object?
Any help would be appreciated. I've researched this issue but haven't found very much documentation out there.
Don't do this. You're in for a world of pain trying to launch Excel in a web application, especially from PHP.
Microsoft Office apps such as Word and Excel are not designed for server side use. When you try to instantiate an Excel "COM object" you're spinning up a full instance of Excel as a separate process. That is hugely expensive and will never scale. Not only that, to add to your woes, if for whatever reason your script can't release and shut down Excel you'll end up with tens or possibly hundreds of orphaned Excel processes hanging around in memory.
Try something like: https://github.com/PHPOffice/PHPExcel if you need to read and write Excel compatible spreadsheets.
I need to convert an Excel(.xls) spreadsheet to a PDF document with an image in PHP. If there is a library available please put the link.
Note - I have created excel(.xls) to PDF with "PHPExcel" library but my output is without image and border.
If PHPExcel can't do it, then you're stumped for a straight PHP solution, and might have to look at options like COM.
You don't mention what your problem is with the borders, and these have been a problem for some time in PHPExcel... the 1.7.6 version of PHPExcel resolved some of these issues, and there is a patch listed in the Issues section of the PHPExcel site that fixes some other problems with borders.
You can convert XLS files to PDF on Linux by installing OpenOffice
with a PDF writer as the default printer driver.
Then, you can call OpenOffice (from PHP) using the "-p" command-line
parameter, which will cause it to load a designated file and print it.
For example, if your file was "accounts.xls" you would call the
following command:
soffice -p accounts.xls
OpenOffice would load the "accounts.xls" file and "print" it to the
PDF writer, which would be configured to save the PDF document to the
desired filename.
GhostScript is a suitable PDF writer.
The OpenOffice setup guide describes how to install and configure
printer drivers using the "spadmin" utility, and discusses the use of
ghostscript as a PDF writer:
"Open Office Setup Guide - Appendix"
http://www.openoffice.org/docs/setup_guide/appendix.html
You can call OpenOffice from PHP by using the backtick execution
operator, or the "exec" function. You may also need to use PHP to move
and/or rename the resulting PDF files:
PHP: Program Execution Functions
http://www.php.net/manual/en/ref.exec.php
PHP: Filesystem: Rename
http://www.php.net/manual/en/function.rename.php
OpenOffice is pretty good at processing XLS files, but it may not
perfectly render every such file - so if you need the ultimate in
compatibility you will have to use Microsoft Excel on a Windows
Platform or emulator. "IT AsiaOne" looked at several alternatives to
Microsoft Office (including OpenOffice) and wrote that "while none of
the alternative suites promise ... full compatibility with Microsoft
Office-created documents, in general, they do a decent job of
translating Microsoft ".doc", ".ppt" and ".xls" file formats":
IT AsiaOne - Specials - Yours For The Picking
http://it.asia1.com.sg/specials/mmedia20020724_001.html
Additional links:
OpenOffice.org Home Page
http://www.openoffice.org/
Ghostscript Home Page
http://www.cs.wisc.edu/~ghost/
PHP Home Page
http://www.php.net/
Google search strategy:
openoffice scripting pdf linux
://www.google.com/search?q=openoffice%20scripting%20pdf%20linux
openoffice print "command line"
://www.google.com/search?q=openoffice%20scripting%20pdf%20linux
followed by a search for "command line parameters" from the
openoffice.org home page.
Ref