Exporting WebBrowser to PDF with userform or in spreadsheet - excel

I am implementing a feature to my excel-program that will show me a map (from google maps) of some coordinates. The idea is to be able to export this map with other pages to PDF. It looks like I have two options:
1) Inserting a ActiveX "Microsoft Web-Browser" directly in to the worksheet and then having excel export said worksheet to a PDF.
2) Inserting a ActiveX "Microsoft Web-Browser" in a userform.
My problem for 1) is that it doesn't seem to work for newer version of excel (2013>), but it does work for Excel 2007.
The problem with 2) is that it is hard to export a userform to PDF when you also want 2 different pages from the workbook in the same PDF (I do not know if userform1.printform has that feature).
My question is if there is either a way to insert a Web-Browser directly in Excel, for all versions of excel, or a way for a macro to export both worksheets and userform in the same PDF.

I suggest the legal way number 3) Using the Google Maps Static API to download a map as image to a temporary folder and import that image (dynamically) into your Excel file. Then you can export that Excel file to PDF as usual.
The Maps Static API service creates your map based on URL parameters sent through a standard HTTP request and returns the map as an image you can display on your web page.
This means you can download the image file through a standard HTTP request to your computer and place it into Excel.
I'm pretty sure the ways you try to automate it is against Google's terms of use because automated access of Google's services without using the official API is probably not allowed, no matter if private or commerial use (you might get banned).

Related

How to automatically export a chart from Excel (or Calc) to PNG

The problem:
I'm working on a web application that exports data from a database to Excel, including a chart, which is the main reason for the export in the first place.
Now I would like for the chart to also be visible on the web page, without the need of exporting the data and opening the downloaded excel file. This could be of course done with JS libraries, but seeing as the chart is quite complicated, I would like to re-use existing export to excel instead or rewriting it all over again, now in JS.
Desired solution:
So, this is the best scenario possible: If it was possible to export a chart from excel file to png (or jpg or whatever) without even opeing the excel file, like from a command line or something. Also the generated files open well in OpenOffice, so I could go with that. Then I could just export to excel on server, then export the image from excel, and just send the image to client.
Is something like this even possible? I'm not against a third party program if it would do the trick. If not, what do you think is the next best solution for this scenario?
I have Excel 2016, and I'm generating the excel file with PHPExcel, if that is of any importance.
Posible solutions:
Some good options seem to be to save the document as web page, but I don't know if you can do that fro mcommand line / without opening the excel UI.
Also the Open Office API doesn't look half bad, but I have never used it before, could you export a chart via this API (with Java or something) without opening the Calc UI? I know open office has the --invisible option, that could prove useful.
Alright, this will export the chart as a .png file, but it opens the excel file (and closes it afterwards), you can try this:
Put it into a .vbs-file and run it via console.
Set objXLS = CreateObject("Excel.Application")
Set yWkbk = objXLS.Application.Workbooks.Open("C:\yourpath\yourfile.xls")
'Sheet ID can change of course
Set yWksht = yWkbk.Sheets(1)
Set yChart = yWksht.ChartObjects("yourchartname").Chart
yChart.Export "C:\yourpath\yourfilename.png", "PNG"
objXLS.Quit
Set objXLS = Nothing
No need to use the API. This command worked for me:
"C:\Program Files\LibreOffice 5\program\soffice.exe" -convert-to png "Untitled 1.ods" -headless
For a discussion see: https://ask.libreoffice.org/en/question/2641/convert-to-command-line-parameter/

Exporting data to existing Excel file

I have a system with an Excel spreadsheet template file which is used for invoicing. I would like the user to be able to click a button on an Xpage, which will then open the spreadsheet and enter the latest invoicing data in Excel. I don't mind if Excel is either the application on their machine or on the server, but my preference would be the application locally on their machine.
I've looked into Xagents, as I feel this is probably the answer. I know they can be used to create Excel but I have not been able to locate any mention of opening an Excel file, and entering data into specific cells.
Is this possible?
EDIT: you can use Apache POI for editing and creating Microsoft Office documents. This is a java project which gives you a handle to office documents and this can be used using java.
A good starting point can be the blog of Christian Guedemann from webgate:
http://guedebyte.wordpress.com/2012/09/17/documents-and-spreadsheets-with-xpages-building-the-kernel-part-ii/
(end of edit)
The only way I KNOW and tried to write data from Notes to Excel is exporting the data to an HTML page and setting the Content Type accordingly (e. g. as described here (there are a lot more resources available for taht):
http://www.dominoguru.com/pages/developer2010_xpagexlsexport.html
I am not sure if this is of help but it seems that this project can help you:
http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=ZK%20Spreadsheet%20for%20XPages
As far as I can see this project can load Excel files from XPages - and then it should also be possible to edit the files.
Besides that the only solution I can think of is a Notes Agent that is called from the XPage. This agent can then run in background and do all the excel stuff. After running, the XPage can show a link to the Excel file. Actually this is the solution I would consider to implement - but maybe others step in with better answers here.
You don't want to introduce a dependency on Excel in your application -- wouldn't work with an iPad front-end. Rather have a look at the ZK Spreadsheet, it will fulfill your needs.
However if you have to have Excel, then you need a roundtrip solution: load the Excel from an URL (probably generated by an XAgent (?) and save it back. The saving back part is the tricky one. Normal HTTP doesn't allow that. What you need there is a webDAV capable server. Watch out for a project on OpenNTF soon (just clearing IBM legal) that provides webDAV.
However the ZK Spreadsheet looks much better for your needs.
I have a sample database at the following URL --> http://www.nnsu.com/nnsusite.nsf/%24%24OpenDominoDocument.xsp?documentId=B65507CB2DE15B3286257986005F061D&action=openDocument
Download the APCC.nsf. This will allow you to create/read a new EXCEL spreadsheet and then stream the resulting file to the requesting browser. There is not need to have EXCEL or office installed on the Server.
THe examples create a new workbook, but you can also store a "template" on the server or in a notes document and use it as a starting point and then save it to a document or stream it to the requesting browser.
With Apache POI you can read/write to a spreadsheet using data from the notes document the process is initiated from.

Excel hyper link function doesn't get converted to PDF

I am developing a small excel plugin. As part of it I need to convert my excel document to PDF format. How can I do that? All the plugins and printers that I've found do not convert links created by the hyperlink function.
I know this is not programmatically related per say, but I am developing this software, and vba is quite a reasonable solution.
Thank you all very much!
I'm not sure any solution will work using the hyperlink function. The reason is typically the convert to PDF functions like a printer driver and the 'printer' only gets the helper text information not the underlying URL. But, using PrimoPDF, any text formatted like a URL "http://www.stackoverflow.com" for example, will get converted to a clickable URL (in the modern readers).

Sharepoint List to PDF report

I have a SharePoint list and I need to transform it into a document (any type) and export it to PDF. Would you have any tips on the best way to do this? I have Crystal Reports but not sure if this is the correct use case for this.
You can programatically access the document library using the object model or via web services.
If you use the object model. You can use the SPContext object to get the current site/list. From there, you can iterate through the items or, you can use a method on the SPList object to turn it into a dataset which you could then use to generate a PDF using some kind of PDF library (e.g. PDF4NET). If you go this route the best way to roll it out is by packaging it up as a feature in a solution file (.WSP) which you can deploy to your farm. In this case the code would be running in the share point environment. You can get pretty fancy with this and have something like a "Print PDF" menu option in the action menu for all lists.
On the other hand, you could also access the list remotely using the web services. In such a case you could just use this as a data provider for your reporting package.
The PDFsharepoint tool (http://www.pdfsharepoint.com) can be used to generate the PDF output. Nice thing about this tool is that you will "design" or "import" a template using WYSIWYG editor and only map the data. Without mess of coding your own PDF generator. It is not free tool though ...
I have had much success using MS-Access for creating PDF reports from SharePoint lists. You can even embed the report as a view in the list. When you select the view, it opens Access for you. Plus you can join multiple lists and even other data from within access.
Access 2007 will save a report as a PDF or you can use a PDF printer adapter such as PDFCreator.
The easiest way to export SharePoint list to pdf is, first export the list as Excel file. Then save the Excel file as Pdf document.
There is a 3rd Party product that automates this.
i-PMO's "SharePoint Data Miner" can be used to create a RS Report across any list data, then use the their SharePoint site Report Viewer and Document publisher to output the report as a PDF into a Document Library.

How do I import an Excel Spreadsheet into a blog..?

We are interested in trying to import an Excel spreadsheet into our Blog.
A sample of the Excel spreadsheet that we generate each day and want to export into our Blog is located at:
http://www.wallstreetsignals.com/WhatsWorking.html
Our Blog is located at:
http://whatsworkinginthestockmarket.blogspot.com/
We are interested in a program or method that would allow us to just import the Excel spreadsheet into our Blog instead of having to hand input all the data, which is what we are doing now.
Thank you for your thoughts and the cost to have you help accomplish our goal.
Philip
WallStreetSignals.com
Well, outside of creating a program (which is possible, using PHP, Perl, Java, etc and either an excel input module or converting to CSV or XML and processing that)...
Have you considered using Google Documents or another online spreadsheet software? It's easy to import an excel spreadsheet, and then embed the spreadsheet in the blog post or webpage. Then if you need to change it, modify the google document spreadsheet and the changes are rendered on the webpage or blog post immediately.
-Adam
The easiest thing might be to use Google Docs. Upload your spreadsheet, then publish from Google Docs to your blog. See this article.
Can your blog consume XML? You can set up an XML Schema in Excel 2007 and just export it to an XML file. You would need to write an XSLT.
I also have a macro that will write out XML to a file... can upload that if it would help...
If your spreadsheet is generated by a macro, you could just modify a macro to generate html or some other sort of blog markup ready for copy and paste.
Excel can save as HTML, which you could then strip the metadata from and use in your website. Unfortunately the HTML that it generates is very bloated. If you do not mind client lock-in, you could consider embedding the XLS file directly on your website, and having your viewers use the IE embedded excel viewer.
If you can use ASP.NET you could use SpreadsheetGear for .NET to load an Excel workbook, grab values, formatted values or even images to display on a web page. There are live ASP.NET samples with source if you want to check it out.
Disclaimer: I work for SpreadsheetGear LLC

Resources