Good day,
How do i create an msexcel file using php script?
I have already prepared my data in a well structured array. I need
to be able to format my array into tables in msexcel.
the server where the WAMP server is running has no MS Office installed, would it
affect my objective to create the msexcel file. do i need to install on msoffice
in the server in case? fyi, i dont actually need to save the excel file in the server
but can be an option too.
thanks.
This is really a spin on DaveRandoms comment.
Make a CSV and set the mimetype to any of the ones in this SO question.
That way Excel (or any equivalent application) will start and show the file.
The PHPExcel library will let you take your data and write it into a valid Excel file, whether you need old-style XLS or new style XLSX format.
You don't need to have Excel installed on the server to use it.
Related
I want to read an Excel file with PHP row by row because reading the entire file at once cause memory overflow.
I have searched a lot, but no luck until now.
I think PHPExcel library can read chunks of an excel file, when you implement the filter class, but each time it gets this chunk it reads the entire file, which is impossible in huge .xls files because of the time it will take.
Any help ?
This may be something that is totally out of question, but from the information that I get from your question the following seems like an obvious option, at least something to consider ...
I get the impression that this is a really big file that needs to be accessed often. So, I would just try to import its data in a database.
I guess there is no need to explain that databases are masters in performance and caching.
And it is still possible to export the contents of the database to an excel file afterwards.
MySql works great with PHP and is certainly easier to access than an excel file. Most php hosting providers offer a MySql database by default with a PhpMyAdmin management tool.
How to do it:
If you have PhpMyAdmin installed, then you can follow these simple steps.
If you have command-line access to the server then you can even import the file from commandline directly to a MySql database.
If the only thing you need from your read Excel file is data, here is my way to read huge Excel files :
I install gnumeric on my server, ie with debian/ubuntu :
apt-get install gnumeric
Then the php calls to read my excel file and store it into a two dimensionnal data array are incredibly simple (dimensions are rows and cols) :
system("ssconvert \"$excel_file_name\" \"temp.csv\"");
$array = array_map("str_getcsv", file("temp.csv"));
Then I can do what I want with my array. This takes less than 10 seconds for a 10MB large xls file, the same time I would need to load the file on my favorite spreadsheet software !
For very huge files, you should use fopen() and file_getcsv() functions and do what you have to do without storing data in a huge array to avoid storing the whole csv file in memory with the file() function. This will be slower, but will not eat all your server's memory !
Hi I have a MAMP server set up on a mac I am using and I have this displaying a calendar using the php icalendar source code. I am trying to have this display a public calendar which I can do but I need it to be up to date so I need it to import the Calendars csv file regularly. So my question is does anyone know how I could go about programmatically exporting a .csv file from a public calendar and how I could then import it into a certain location on a server again via a script or code?
Thanks a lot
There are a lot of ways to download the .csv file.
You could use fopen, cURL to download the file. For fopen you need to enable to read files from an url.
An other way, must be supported by the other party. Is to use ftp.
I think the best way for these is just look at php.net how to let them work.
Second you want to make a scheduld job. I don't know it in macs, but with linux you can make cron's you can say these need to be run every x time (1min, 1day 1 week).
In the script you do the download and update part.
Hope it helps
I develop webapp with PHP5 to read or to actualize xlsm files.
I have tried with PHPEXCEL, but this library not supported xlsm-files format.
Everything what I need, is open the file, write the data in there and stores as a xlsm-file.
The macro should not be changed.
It is important that the file returns which contains the macros because this file it is used daily to do several import. I may not change the file-format.
if somebody has tips or tutor's courses for this specific task has, please writes to me.
Thanks 4 your help
If you need to retain macros from an Excel template, then you'll need to use something like COM because there aren't any other libraries that handle macros from PHP
xslm files are actually ZIP files with XML documents and other assets inside them. PHPEXCEL and other similar MS Office file format readers and writers only read the older binary-blob formats, not the newer Office Open XML formats.
Try using ZipArchive to open the file in PHP, and one of the PHP XML libraries to read the xml inside the file. As long as you don't alter the macros, the macros will be preserved.
However, if you actually need to execute the macros, you need a full Office runtime. In this case you must use COM on windows with a copy of Office to run the file.
I have the excel file with the following fields
First Middle Last Email
michael j jackson michael#plantgenomesciences.com
mary j watson mary#microsoft.com
jeff a bridges jeff#rediff.com
nick h gill nick#gill.com
If possible please tell me how can i get the data from Name Box (K8) from the same file
I want to know how can import this data into the php (I m able to upload the excel file on the server)
by using simple code (not any premade script)
Typically for files like spreadsheets, CSV import is most used. You can export excel file to csv. and then import it using PHP.
See http://in.php.net/manual/en/function.fgetcsv.php
But it seems you are looking to read excel files, you may need help of third-party libraries for that. You also have a look at the following article:
http://www.ibm.com/developerworks/opensource/library/os-phpexcel/
You won't be able to write any simple code to read a BIFF file yourself in any reasonable timeframe. Your only quick solution, given an unwillingness to use a library capable of reading BIFF files, is to convert it to a different format (such as CSV) before uploading it.
Alternatively, if you're on a windows server, you could try using PHP's COM extension (as long as you install MS Excel on your server)
I need to export a report to Excel file using PHP i.e. on the fly. I am actually getting data from MySQL and presenting it in HTML tables.
I am able to export all this data into Excel file format, except images. I can't point the image source to an absolute URL, because this file also needs to work off-line.
Is there any way I can embed/insert images into this Excel file without using any library i.e. only PHP code or library which doesn't require PEAR/PECL extensions. I am using LAMP stack, so COM is not an option.
I'm not sure what your reasoning is for not using PEAR, but there is a modified version (PHP Excel Creator library) of PEAR Spreadsheet Excel Writer which does not have any dependencies on the rest of PEAR.
I know that the original PEAR version has a method Worksheet::insertBitmap() . You would need to convert the images to bitmap if they aren't already (maybe using GD
in PHP)
If you are on Windows and have decent access to the server you could also try using COM to talk to Excel and generate the file that way.