AS3 - Exporting data from Flash for use in Microsoft Excel - php

I'm producing a Flash tutorial project in Flash Professional CS5 using the ActionScript3 programming language, with my SWF optimised for Flash Player 10 (or higher).
My question relates to whether it is possible to write a Mouse Click function in AS3, attached to a button, which when clicked exports numerical/string data held within an array in Flash into a new suitable file format (such as CSV/XML), which my user can then subsequently open, view and edit in Microsoft Excel? This data wouldn't need to be passed back to Flash at any stage.
My tutorial is likely to be embedded within a web page or framework rather than sitting on the desktop. Can Flash conceivably 'package up' array held data and produce new file types? From reading around the CSV and XML file formats look my best options if the user is to study the data exported from Flash within the Excel software package?
If I'm embedding the project on the web, is there any PHP additionally required, which could aid in this re-packaging process and post the CSV or XML to a file location on the server or even better the user's hard-drive? Can Flash 'talk' directly with Microsoft Excel and do a conversion, export and open, or at best would the user be able to just get hold of the CSV/XML text file and open the file themselves manually in Excel?
A number of questions I know, but if any developer who has encountered (and hopefully conquered) this type of problem could provide me with some guidance or even better some example AS3 code which tackles this issue, I'd be extremely grateful.
Kind Regards,
Joel

try this solution Writing to CSV file in AS3 - simple as3 code or csvlib on google code.

I will post an example of this later:
Create a PHP page to output to Excel
Post the data to the PHP page (use JSON for ease of use)
Parse data on PHP side to generate adequate Array structure
Output the Excel sheet from PHP
Export Excel from PHP:
1) http://code.google.com/p/php-excel/
2) Alternative for PHP_excel
3) http://forums.digitalpoint.com/showthread.php?t=60681

Related

PHP to MySQL and Google sheet?

A few months ago, my supervisor needed me to create a form to collect some data - at the time, the most sensible thing to do was just to whip together a Google Form, no problem. Now it turns out that the data collection program needs to expand, and it makes more sense to direct the form to a MySQL database (using PHP) instead - again, no problem, already done. However, for reasons I won't elaborate on here, my supervisor still wants that data to go to the original Google Sheet as well.
My question - is it possible to submit form data to two separate sheets when one is a MySQL table and the other is a Google Sheet?
Thanks!
I know that feel bro ;)
There's some resources to handle boss requests:
PHPExcel Class 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, HTML...
You will need an script to process the outputs.
Excel / CSV > MySQL
MySQL > Excel / CSV
If you need directly to work with Google Docs, you will have to follow the previous steps and play with the following project:
php-google-spreadsheet-client is a library that provides a simple interface to the Google Spreadsheet API.
You will need to store data in MySQL and pass it to Google.
Second idea:
If your boss neet it NOW, you can give a chance to Zapier and do it fast. If you don't need a very fast sync time, it can be a good free option.
I hope it helps :)

HTML with JScript to read/write XLS file

Very sorry if this is not in the right place etc. I have been researching this for a while but its raised more questions!
I have developed a spreadsheet which I use to set a teams duties for a shift. There are 5 teams, each with staff which can change day to day.
the spreadsheet works fine, but its too complicated for some users. I am therefore trying to develop a straightforward web based form.
All the data is on the spreadsheet, held on a network drive (essentially locally).
I need to be able to have several combo/select boxes which get their values from a range of cells from the XLS. Along with the ability to output the final selections to a XLS sheet.
Finally, it needs to be able to load the previous day values on load.
What is the best way of developing a web page for this? Is Jscript the best option? Can I access a local file with jScript?
Thanks in advance
Adrian
The easiest option for you is to use google web forms. These allow creation of forms that will submit data to a google spreadsheet. Which is essentially an uploaded version of your local spreadsheet and can be downloaded to excel.
In case if you want more control and programming, pure javascript cant play with files, you need server side too. Javascript is not necessary unless you want to make your app do some visually fancy stuff. Since you mentioned php as a tag of this question, it seems you are a bit familiar with php. The task you have mentioned can be done using php programming as below:
Read excel file using an excel plugin
Parse relevant data using a text matching function, may require regular expressions knowledge.
display the form by building up the html and putting in the variables using the data obtained above.
Write a method to save the data submitted by the form to the same excel file using the excel plugin.
As its not convenient to play around with excel files. A better option would be to generate csv file or use a database using a database class . csv files can be parsed easily using text.

Run excel formula from php

Here's my clients scenario my client wants to put a excel file on server now from a PHP form
sends data to the file runs a formula in this excel file and get the results.
I don't know if this is possible.
If so direct me to a library best was PHP, or some other possible solutions.
It's perfectly possible: take a look at the PHPExcel library which has a built-in calculation engine for handling most Excel formulae
There's an example of populating an Excel file with data (in this case from a form input) then rendering a formula in that Excel file to generate a result an ddisplaying it to a web browser in the /Tests/ directory of the distribution. This simple example /Quadratic.php solves a quadratic equation; but the principle is similar enough
EDIT
See my response to this question for some indication of the limitations of PHPExcel's calculation engine
EDIT 2
The PHPExcel is deprecated, hence now you can use PhpSpreadsheet
You are thinking in the wrong direction. Instead trying to send the data to the excel file, read the excel file in you PHP script and do the math there.
Trying to send dynamic data into a static XLS file wont work.
And you can add a regular cronjob, that checks if the XLS file data has changed, if it has, then run your calculation again.

Share excel data across real-time?

I have developed a VBA spreadsheet that runs locally and with obtain data from other sources continuously.
I want to find a way to extract / access the data inside this spreadsheet through php and then output some processed data using a browser and these data will update accordingly as the spreadsheet updates itself.
Anyone can show me how to achieve this? Both the spreadsheet and the php will run locally on a windows machine if that is easier...
Thanks very much for your help :)
I just developed an application that does this the idea is to use http requests on_change events in the spreadsheet.
vba code for request in excel
Function httpRequest(ByVal path As String) As String
Set HttpReq = CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.Open "GET", path, False
HttpReq.Send
httpRequest = HttpReq.ResponseText
End Function
On your php side you have to develop the part where the data is mapped in the database. And of course the view of the data. As for realtime you have to go for something more elaborate like a table that holds the latest changes and check for such changes every now and then unless there is some mechanism to do so.
In excel there exist timers to acomplish polled checking for updates
for web you should to use ajax for seamless updates have a look at http://datatables.net/
You can use PHP Excel Reader to display the data quite easily from the spreadsheet - I think this is the simplest of the PHP Excel libraries that will do what you want and simply set the page to refresh on a regular basis.
Using this library is pretty much as simple as this:
<?php echo $data->dump(true,true); ?>
Once you have told it where the file is to display the output pretty much as would be expected to see in an Excel Workbook. (Here is a link to an example that they have up and running online)
This means you won't get any locking issues as the read is done rather quickly (assuming a reasonable file size and users won't really ever be more than a few minutes/seconds behind.
You want PHP to just generate HTML from Excel sheets? Excel supports HTML generation natively.
Try Save as Web Page to test the quality of HTML produced by Excel. If it's OK then all you'll have to do is write a small piece of VBA that will be generating HTML from your spreadsheets automatically.
Sort of CMS build in Excel.

PHP make real time stock exchange application

I have a software which give me stock data as excel format , the data is automatically update continuously in every second.i have to show these data in web page such like they are shw in excel (ie the web data should be also update in such manner ) and these data. how it is be done.
Programatically export the data into CSV format and import it into a relational database.
Extract the data with web language and display in webpage. Tutorials for these steps should all be available.
To convert from xls to csv see the question...
converting an Excel (xls) file to a comma separated (csv) file without the GUI
For the second part, you can have a cron job run a PHP script that reads in the csv file contents and inserts this into a database. Plenty of threads on this also.
To display, select from database and format appropriately, can follow any of the basic tuts on the net for this part.
Post your code if you get stuck :)
As you've been told, use PHPExcel to read Excel file.
However, refreshing data every second is gonna make a very heavy load on your server.
I'd recommend you rather use server side push using Comet technologies. Take a look at Meteor server.
You will accomplish 'persistent' connection, so server will push data to the client, and the need to refresh the page or create ajax request every second will be gone.
You've tagged this PHP, so I assume that's your scripting language of choice: use PHPExcel to read the Excel file and write it out as formatted HTML to your web page. PHPExcel's HTML Writer will retain all the style and formatting of the original Excel workbook.
However, an update every second is pretty extreme for a web page, and for a scripting language. Rather than reading the Excel file whenever the page is requested, run this as a background task converting the Excel to a static HTML file whenever an Excel file is received, and serve the latest static HTML.
If this extreme timing is needed, then you might be better looking at a compiled language, or even a non-web solution.

Categories