Excel to PDF conversion in PHP - javascript

It is asked to me to do a small excel to pdf conversion.
Let me describe what is exactly to be done.
in excel file there are list of companies which looks like this...
and to retrieve a company name turn into this in PDF format, like this...
I am thinking to follow a path...
1-using php and js I will get excel file with "input type=file"
2-using pdf reader php script I will retrieve the data required.
After this I am confusing...
3-I can retrieve data by searching and parsing a company name( for example getting an input: "company:A") till next keyword of "company" for all columns
or should I put all data from excel into CSV file and do the parsing part there???
4- after that, I am thinking to use, one of the tcpdf example methodologies however here comes another confusing point for me... because I don't know which type of output should get from excel or csv and load into pdf converter method.
An enlightening path would be appreciated since I am confused
Regards

Build your Data on HTML format first then if you got the correct display on html then you can now convert it to a PDF file.

Related

how to create excel file from HTML

There are too many examples how to create EXCEL file, like this:
create Excel with xPages
But I really need Excel xlsx format not xls. Just defining xlsx file extension and change content type doesn't help:
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
Vlad,
Setting the content type to xls or xlsx has the same effect: it tells the browser to hand over to Excel. It still would send HTML that excel renders.
It is up to the user to save as xlsx.
If you really need a ready made xlsx you need to create an XAgent that renders the binary xlsx format. The easiest way is Apache POI library, which is available for XPages through OpenNTF.
Check the samples there. They should do what you need.

Saving pdf on server side with jsPDF

I have an application that generates a HTML page with data which the user can edit.
At the end I generate a .pdf file with jsPDF.
Is there any way that I can save this generated .pdf on my server-side database?
I'm using PrimeFaces.
Thanks in advance
Updating my solution for other users:
I found the .output('datauristring') method of the jsPDF which returns me a BASE64 String.
Then the String is sent via JSON to my backed bean and converted as my will.
Thanks all for the help! I've found my solution:
Once the user presses on the button to generate the .pdf, I'll save all the data he filled on the database, just the data.
When the user wants to see the pdf he generated back, I'll generate a new one with the data collected on his first submit.
Thank you all for the answers, they were helpful.
I suggest to use wkhtmltopdf.
It is a open source cross platform command line tool to generate pdf files from html content.
So to your requirement what you can do is, you need to send the html content to the server and save this content into a html file.
Once you saved html content into html you can call wkhtmltopdf like you execute MS-DOS commands in java.
Example: new ProcessBuilder("wkhtmltopdf.exe", htmlFilePath, pdfFilePath);
Once pdf file is generated you can read and store into database.

Proper way to export HTML table as Excel file?

What's the correct way to export an HTML table as an Excel file so that the user can click a button and download the Excel file (ideally using Angular and without using server)?
I've seen many answers like this:
Export to xls using angularjs but doing this gives an error similar to the following:
"The file format and extension dont match... The file could be corrupted..."
and I believe the file is actually in HTML or XML format, not actual Excel.
The warning does not present a good image to the user.
What's the right way to actually export a file as Excel without using the server?
Or is the server required to create the file?
If you are just using tabular data, then I would argue that the best solution would be building a CSV file. This could be natively opened by excel and converted into an XLS file if necessary. You can do so by arranging your data with a data URI. The octet-stream will force a file download rather than opening in browser. Here is an example:
CSV

CSV is too large to be processed via AJAX

I'm having a problem when sending large amounts of data through an AJAX request. I'm pulling in an XLS file from a website and attempting to pass it through an API by parsing the data. I'm doing this in VBScript/Classic ASP so there is no native function to parse XLS so I'm first attempting to convert it to a CSV file through Javascript.
I'm using something called SheetJS (http://oss.sheetjs.com/js-xls/) which is a great tool and it works just as I need it to. I can run an Excel file through it and it outputs the correct CSV data. I then try to send that data via AJAX to the ASP page with my code and I get a 500 error that I've isolated to being an issue with the file being too large. I was able to isolate to about 1652 lines of my Excel file and anything past that generates a CSV file too large to send.
All I am getting is a 500 error so I'm not really sure what else to do from this point. Is there a data limit on AJAX functions? Or is it a time limit type issue? I don't know how to find out which it is. Any suggestions on how to get a more detailed error message AND any fixes for this issue?
While you can't work with .xls files natively in VBScript, there is ADO that makes it easy to do that via COM. This way scales well wrt memory. Start your research here.

How to export a .xls file from a website as a CSV file?

I am trying to export self updating .xls file from other website to mine as csv, so that I will be able to create "Live data graphs" using Highcharts JS for different parameters from this , which also update automatically according to the file.
OR
I have another method, same self updating data is on a website in form of table which gets updated with time. So , is it possilble to pull data from there for specific parameters and generate live data graphs?
Please Help.....
How about using a Google spreadsheet?
http://dataist.wordpress.com/2012/11/23/using-google-spreadsheet-as-a-database/
If I got you right, you want to convert an .xls file to .csv ?
Then you'll want to look at this article:
http://www.c-sharpcorner.com/uploadfile/yuanwang200409/how-to-convert-xls-file-into-csv-file-in-c-sharp/
As well as consider some answers on SO:
Is there any simple way to convert .xls file to .csv file? (Excel)
C# converting .xls to .csv without Excel
Personally I like the solution to extract .xls into dataset and then generate you .csv from datatble. (see c# datatable to csv)

Categories

Resources