Discuss Excel Processing in the PHP Development forum on Dev Shed. Excel Processing PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month! Download and Activate to enter!
Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.
Posts: 118
Time spent in forums: 17 h 21 m 40 sec
Reputation Power: 7
Excel Processing
All,
Trying to get a good run of Excel classes or extentions. I Googled and downloaded twelve (12) versions of these, including the Official PEAR class set.
Need to do the following:
Read browser selectable Excel SS into array (got the file selection part working and can view, but can not load the array),
Map Arrays (Originating SS to Target SS),
Rewrite Array from Array Map,
Write to target Excel SS from resulting array,
Everything I find and read on this, is either lacks examples or is extremely challenged. All the documentation on these classes and/or extensions are horrible, leaving the in-experienced user/programmer to hash through tons of code to find the correct functions, classes, extension. Even the PEAR sight has virtually no information on their contribution to this.
Almost all say they are/were based on PEAR, but most claim to be modified so PEAR is no longer needed. I think my problem is a simple one, but it has taken me five(5) days just to find a set where I could just open an Excel file, and then I does it in "download" mode not direct open, so it is a copy of the file, not the source file that finally opens.
I just want to step-by-step solve my problem, or at least find a readable reference manual that describes the classes, functions and extension, so I can actually use/call them, with confidence.
Please let me know what additional resources I need to look at.
Posts: 454
Time spent in forums: 1 Week 1 h 45 m
Reputation Power: 57
I can help with writing a spreadsheet using the official pear classes.
PHP Code:
require 'Spreadsheet/Excel/Writer.php';
$workbook=new Spreadsheet_Excel_Writer("pathtowhereyouwanttosaveyourexcelfile.xls");
$worksheet=&$workbook("worksheetname"); // you can do multiple worksheets just do a different variable and worksheetname
$a=0;$b=0; // column and row counters
$worksheet->write($a,$b, "whatever"); // $b++ would move one column to the right - $a++ would move one column down
$workbook->close();
Quote:
Originally Posted by OldManRiver
All,
Trying to get a good run of Excel classes or extentions. I Googled and downloaded twelve (12) versions of these, including the Official PEAR class set.
Need to do the following:
Read browser selectable Excel SS into array (got the file selection part working and can view, but can not load the array),
Map Arrays (Originating SS to Target SS),
Rewrite Array from Array Map,
Write to target Excel SS from resulting array,
Everything I find and read on this, is either lacks examples or is extremely challenged. All the documentation on these classes and/or extensions are horrible, leaving the in-experienced user/programmer to hash through tons of code to find the correct functions, classes, extension. Even the PEAR sight has virtually no information on their contribution to this.
Almost all say they are/were based on PEAR, but most claim to be modified so PEAR is no longer needed. I think my problem is a simple one, but it has taken me five(5) days just to find a set where I could just open an Excel file, and then I does it in "download" mode not direct open, so it is a copy of the file, not the source file that finally opens.
I just want to step-by-step solve my problem, or at least find a readable reference manual that describes the classes, functions and extension, so I can actually use/call them, with confidence.
Please let me know what additional resources I need to look at.
You can see I'm using two different Excel class libraries, but neither works the way I want and here is why:
TBS opens the source file, but copies the sheet and does not use the original
TBS does not read the source into an array
ExcelReader does not open the file in native form
The source form uses VBA to build a secondary sheet when opened
ExcelReader does not open the file in a way where the VBA secondary sheet can be read
Result: I get basically a blank array, with no usable data. So I need a little advanced help on how to open the sheet so all VBA processing works and then read into the array for array processing to the target output file.
Hope this clears up part of the problem, at least where I'm currently stuck at.
That reader is almost the same as the one I have, notice my:
Code:
lineno#14 require('Zips/ExcelReader/reader.php'); //Load Excel Reader Class
statement. I had downloaded one like this but hate long names so renamed "Spreadsheet_Excel_Reader" to "SS_XL_RDR".
The class in the link seems to have a few more extensions, but basic problem with this is it does not open in native mode, therefore the VBA macros do not run and therefore my data array is blank, as the macros build new sheet and then display that with all data. Basic sheet only has 20 fields propogated and those are constants, which do not appear in the final output sheet.
I think I need to run an "exec(filename)" type of command to open the sheet, with the sheet assigned to a handler, then have an excel class, which can read the sheet within the handler.
Not real sure how to make that happen as all my attempt to run Excel from command shell just give errors. That why I was also experimenting with the TBS class as I will actually run/open the file is a way which executes the macros and gives me a viewable screen with all the data displayed.
Trying to see, if they have a "visible" option, so display could be turned off for background processing. I think if I leave out the $TBS->Show(); statement I can do background processing, but not sure. Still experimenting with that. May need a new class to "Run Macros" to avoid the prompt that comes up when $TBS->Show(); displays the file.
Also experimenting with the properties stored in the $TBS->PlugIn function/class to see what I can use to actually read data. Thinking I'm problably going to wind up copying some cell/data reading functions from the "ExcelReader" class into the TBS class to fix this.
Maybe I'm trying to design a whole new Excel class? Not sure?
Anyway, was surprised at lack of IRC support, since this should be fairly routine for many programmers, so started channel #XL-VBA on irc.freenode.net. Maybe we can get some interaction going and fix it. Willing to share the code, when it is done.
Posts: 118
Time spent in forums: 17 h 21 m 40 sec
Reputation Power: 7
Almost There
All,
Maybe you didn't notice, but this project turned out to be much larger than I thought.
Anyway I finally got all the reading done and now working on writing the second file.
I had to break up the output into two (2) MySql tables as 1.) one table deals with header and footer information, for both input and output EXCEL files and 2.) the second table deals with itemized rows.
In particular this is a problem as you notice the output EXCEL file only has ten (10) rows to write into, and the input EXCEL file has 300 rows of data. Now selection (query) of data from the first input file is on the "QTY" column, which we ignore if blank, so usually less than 10 rows are active. But when more than 10 row result from the query, then new rows have to be inserted into the output EXCEL file, conserving the formatting from the row above and then renumbering column one, for all remaining detail item rows.
I'm uploading the source for where I'm at. I used:
[li]TBS to open/view the source file, [/li]
[li]Excel Reader to read my values[/li]
but now have to find a different class to write with.
If you have a single class that can do it all, it would be helpful and jumping in here to help will be appreciated.
Files attached. Second is EXCEL source, which is large.
Posts: 118
Time spent in forums: 17 h 21 m 40 sec
Reputation Power: 7
RoadBlock
All,
Hey I got all it working but the write to the new SS.
On the subject of write, when I look at all the docs on the Excel Writer Classes, everyone assumes new file, new workbook, new worksheet.
Nothing could be further from my situation! I have a .XLT template with a specific "NAMED" worksheet that must be written to.
Therefore none of the docs fit my problem and I have not yet figured out how to find my worksheet in the writer. Finding worksheets seems to be a "READER" function not a "WRITER" function, so I seem to be at an impasse right now!
Suggestions on how to approach or solve this portion would help me get around my current road block.