There is alot of info on converting HTML table to EXCEL which is actually what I intend to do.
However, none of the examples work so am looking for a more brute force solution converting the whole web page. I have noticed by renaming the extension from HTML/ASP to XLS the conversion is fine (good enough for my needs anyway).
So...
I have an ASP page with large amount of table data which by clicking a button I need this to open up a save dialog box with the file format as EXCEL only and not HTML/ASP etc. Then the user can choose where to download it and open it up as EXCEL Spreadsheet at discretion.
Appreciate the help.
in ASP all you need to do, is to create a link to the .asp page containing the table, and add the following lines to that .asp page, before any html tag :
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=fileName.xls"
Related
I am currently working on a web page that should do the following. As a little background, we are working on uploading a bunch of data that has a decent level of user-errors in the cell formatting to a database.
The data is stored in Excel spreadsheets. The spreadsheets are formatted in the same way, (99.9% of the time) but occasionally there are some wonky values within the cells themselves. Here is my goal: I would like the user to be able to
1) Provide the excel file to the page
2) Parse the file with PHP, then send the newly extracted data to a table on the page with editable cells
3) The user can see what came out of their file, then correct it for any slight errors before choosing to send the extracted data to the database.
I can do steps 2 and 3 using PHPExcel with a test file stored on the server, but I am having trouble getting from step 1 to step 2. My vision is to have the user specify the Excel spreadsheet and do the parsing without leaving the current page and losing the data in the fields. I would really like to keep the page from changing, as there are additional text fields on the page and I actually have to parse TWO spreadsheets before the data is taken from all of the fields and sent off to the database.
I guess I'm wondering if there's a way to use a client-provided file in PHP without doing a POST to upload. OR if there's a way to upload the file and have it parsed without leaving the page. I'm new to web development, so excuse me if those last few sentences made absolutely no sense.
Any thoughts?
PHP cannot do a single thing to the file until it is uploaded to the server. You could put a file upload form in an iframe and do some AJAX-y thing as described here.
As for handling PHP file uploads, the docs have a whole section.
I studied wkhtmltopdf, tcpdf mechanism to generate pdf files. wkhtmltopdf where you directly pass a .html file and it gives you the pdf where in tcpdf you need to code entire pdf.
my case is I'm having a pdf form template Which I've converted into html so user can fill that form and after i fill that template with user entered values then I'll give an option to user to download the html (user filled) file as PDF document, so template will have user entered data next to that labels.
so first
PDF template >> convert to .HTML page >> process with php echoing >> convert it back with user input to a PDF file.
I'm confused here which approach I should use.
Install wkhtmltopdf on server and use it to pass .html page
problem: Everytime I need to save .html page on server and pass again it to wkhtmltopdf.
using TCPDF I need to write lots of code to create pdf exactly same as template PDF docs I'm having
and then using php echoing those user enterted values.
Which approach should i use If I'm expecting 1000+ users will be saving page as pdf at same time, approach which will be more easier and scalable in future.
First of all - I think you should go with the HTML form to PDF approach, so that's either wkhtmltopdf or a tool that already does this for you like PDFmyFORM.
In case you're expecting to go to 1000 saves concurrently then you definitely want to roll your own solution instead of going with an external service though.
There are patches in the wkhtmltopdf issue list that suggest caching (see this one) and you may also want to think about whether all these forms have to be generated as PDF again. You could use APC cache to somehow cache PDFs based on the same values being filled in. That could save you a bunch of time.
Other solutions you may want to look into are for example PhantomJS, which is a headless webkit browser too, but then based on JS - so that may reduce your server load alltogether...
I have to create a document using user inserted data and including data from a .rtf document into a web page layout i created (HTML+CSS and PHP for scripting).
My problem is, i can't find any way to obtain the full content of the .rtf document.
Being a technical document symbols, tables, graphs and images are very often included: with the methods I've found i could obtain the text with symbols in a decent formatting but i had no luck with images.
So what i need is a way to obtain the full content of a .rtf file, possibly maintaining the document formatting, so i can display and organize it in a webpage; preferrably in pure PHP but use of js/executables via php is fine.
I've tried:
-rtf to html converters but the best i could get is clear text and symbols but no images;
using COM extension to open the .rtf in ms word and saving it as .html (i noticed that if i open up the .rtf then save it as webpage in word it creates a perfect html page) but it only changed the extension and didn't create a html page;
extracting text and image sperately: works but again being the document a technical document image placement is very important.
It's my first question here, after many research; please bear with me in case of errors.
I want to read the content from website and save then into a csv file in php, can anyone please tell me how I can do this.
How do you want to save a website's content as csv file? CSV means comma separated values, and it's really easy to save things as csv file but a website's content?
You say "the content from a website" - normally you'll start reading one sites content, which includes html markup, scripts and styles. Or do you only want to get the text contents or some meta data?
If your server supports opening urls via fopen I'd try this one (php.ini option: allow_url_fopen) - otherwise you'll have to use cURL or something.
Here's some more information about reading websites in php.
Regarding the storage of websites as csv I think you should be more precise what you want to achieve.
Regards, Daniel
There's no instant-magic answer for your question. We (You) need to know which website is in question, how the table is presented. If you know everything about your scenario, you should use PHP's DOM functions and parse your table then export it to a CSV.
I am generating a simple csv file using php. The file contains some user's personal data.
When I open the generated file in office, the addresses are not displayed in full height. I have to double click on the cell for the address to be shown fully (in full width and height) otherwise I can only see the first word/number of the address.
Also, I have date of births displayed as ######, I have to expand the whole column to see them fully.
This doesn't happen in open office.
Is there any way to force MS Office to show all fields in full? Because otherwise it'll be to confusing for the people who will use (Hey where are all the details!:)
Thanks :)
I don't think you can "format" your sheets with CSV. You will have to produce some other file format that Excel understands. I would suggest XML which is really easy to generate.
Just make a sample sheet with the data you want, save it as XML and you'll see how your file should be generated.
Or you could use some ready-made PHP solution for writing excel files if you can't be bothered with analysing the XML file.
you could try the auto-size columns feature.
This is a UI issue with how Excel works, you can't force Excel or anything else how they handle it.
The quickest work around is to perhaps create an XLS file that runs a macro to retrieve the CVS file and format the cells as needed, but there's nothing you can do inside the CSV to affect what Excel is displaying.