I am using PHPExcel to read an Excel template and then write another excel file based on that model.
In my model I have 2 sheets: the first one named "Data" contains sample Data. The 2nd sheet contains a graph using the data of the first sheet.
What I'm trying to do:
replace the data of the first sheet with the new data so that the Graph automatically change.
The problem is that when I generate my excel file based on the template, the graph does'nt always appear. And when it does, there is a popup saying that he had to repair the file (I think that's because the formula of my chart refers to the data that is being replaced. PHPExcel override the data so the chart can't load).
Is there another way to achieve this with PHPExcel?
Also, I already included
$objReader->setIncludeCharts(TRUE);
and
$objWriter->setIncludeCharts(TRUE);
If something isn't clear don't hesitate to ask, I don't want to put too much useless informations for you.
Related
for development, i use PHPExcel (https://github.com/PHPOffice/PHPExcel) for creating a Excel (xlsx) document filled with data from a mysql database. So far this works good.
I want to print this Excel document too, as hardcopy to spread around for people reading it from paper. Printing wont be a problem.
The problem lies in: it's a long document, far more rows then will fit on 1 or 2 pages. The worksheet consists of blocks which i want to keep together, when printed, to be on the same page.
I can use a method to set breaks on a row. That i will be able to get to work. But after finishing putting the data on the sheet, i don't know where the automatically placed page breaks are. There is a function (getBreaks()) on the worksheet, which should provide an array with the breaks, but the returned array remains empty, so i can't find out which blocks go over a break.
Can someone help me?
Should i first save the Excel sheet, then open it again and do my job then?
Excel document is created on a shared hosting webserver. No printing options there i guess, at least not where i can manage them.
Other solution is: put a macro's in that Excel document, and let the macro run (to put the breaks on the right places) and print the Excel sheet. (not my favorite solution as i am honest).
I am currently facing one issue. I have an excel sheet with some particular formatting. I have to make a program which can read the data from the sheet and analyze it from my database, fetch some more data and write back to the same sheet.
I know how to read and write using PHPExcel. But I don't know how to write on a given sheet.
Has anybody got any HTML code/know if its possible to fill a table with data from a excel spreadsheet uploaded to the site directory?
I want to display a table of data on my PHP site, and wondered if it is possible to just add the data to a excel spreadsheet and update in the site directory rather than have all the information manually added as HTML rows.
You might want to try out Google Sheets - you can import data from Excel.
Then you can use Sheetrock.
Sheetrock is a JavaScript library for querying, retrieving, and displaying data from Google Sheets. In other words, use a Google spreadsheet as your database! Load entire worksheets or leverage SQL-like queries to sort, group, and filter data. All you need is the URL of a public Google Sheet.
The main limitations are:
As stated in the description. The Google Sheet needs to be public.
This javascript method may not be as fast as php.
At the moment of this writing the current version of PHPExcel is version 1.8.0. I know how to make a chart and embed it in a worksheet, I basically followed the provided example.
Excel allows to either embed a chart into a worksheet or otherwise make a chart sheet. A chart sheet has it's own 'tab' in Excel and Excel keeps the chart scaled to the available size in the window.
Now what I would like to know is: how to add a chart sheet with PHPExcel? Is this possible with PHPExcel 1.8.0 using the 'Excel2007' writer?
As stated by #MarkBaker in the comments, the answer is simply "No" (at least not in version 1.8.1).
In my use case I was using PHP to generate an Excel workbook based on some processed data from different sources. What I did is to add VBA in Sub Workbook_Open() on the generated workbook to move the chart from a worksheet to it's own chart sheet. Then I used PHPExcel->getMacrosCode() to export the binary string of macro code to some file.
Now when generating files I add that binary string with PHPExcel->getMacrosCode(String) and save it as .xlsm instead of .xlsx. It is a bit of a hassle, but this is how I work around this problem for me.
Note that depending on your use case you might also need to generate a certificate to sign the code, to allow your user to always trust macros.
I am having a number of different excel sheets at my end. I need to put their data in the database. There are some predefined fields in database (country,code,start date, end date) which I need to fetch from excel and need to put in the database.
Tried so far :
I have fetched the data and putting it in the database when i know the field names of excel sheets. For example if excel is also having (country,code,start,end) then my code is taking and putting in the data base exactly
Problem
I want this to be automatic upload to database in case the excel fields are not same as i using in my code. Explaining furhter , suppose in my excel fields are (location,location code, starting date, end date). then I also want my program to extract the data from proper field.
I want some kind of mapping utility at my panel so that admin can map the fields once a new excel sheet with new fields are uploaded. so that it maps and fetch the data from proper columns of excel sheets.
Please suggest how to start it with.
Thanks,
You can use library like
http://code.google.com/p/php-excel-reader/
And do a custom app which have admin can select the fields in db for the read columns in excel.