How do I show an embedded excel file in a WebPage? - asp.net

I want to allow an Excel report to be viewed embedded in a WebPage... is there a way?
I don't want to use an ActiveX, or OWC (Office Web Components), I just want to open an existing file from the internet explorer application.
I don't want users to download and then open it.
Using an iframe wouldn't be a problem, but my preliminary tests weren't successful
Any ideas? Is it at all possible?

This has to do with the local person's browser set up and not really anything you can do on your end. If they click a link with the .xls(x) extension, the browser determines if it wants to open it itself or in a new window.
Here 2 microsoft pages on how to change these settings:
http://support.microsoft.com/.../how-to-configure-internet-explorer-to-open-office-documents-in-the-app
http://support.microsoft.com/.../embed-your-excel-workbook-on-your-web-page-or-blog-from-sharepoint-or-onedrive-for-business

You should try using the Excel Web App Embed feature that lets you embed tables and charts from Excel directly on your Web Page. You can even let users interact with the spreadsheet so that they can sort and filter data and use your spreadsheets formulas to calculate make their own calculations all without altering the source.
The Excel Web App and storage is all free from Microsoft. Any data you embed on your Web page can be viewed by all the major destkop and mobile browsers and when you update your spreadsheet the data on your web pages is automatically updated as well.

I think your best bet is going to be extracting the data out of the Excel file and displaying it in a regular HTML table. Excel isn't exactly safe to invoke from a web page and not everyone has it anyway.

Take a look at scribd iPaper Viewer - this is a Flash based Viewer of XLS (and other) docs.

MOSS 2007 has a nifty feature called Excel Services which might fit the bill...

Excel Web App allows embedding "live" interactive spreadsheets on a web page. For an example, see http://datawiz.wordpress.com/2011/01/10/how-to-embed-excel-on-a-web-page/

in your comments you say that the Excel file is on the client's filesystem, not on the webserver. i think the security model of sane browsers forbid this; but wouldn't be surprised if setting high permissions to your pages could allow this.

<iframe src="file:\\yourpath\yourfile.xls" width="100%" height="500"></iframe>

Well this is a bit crude but sort of fits the bill.
Select the area of the spreadsheet you wish to display.
Copy this area into MS Paint.
Select the area in Paint and use the Edit/Copy to/ function to save this as a bitmap.
Now load the bitmap as you would any other pic.

Related

How Do I convert HTML to PDF with hot links in outputted PDF with ASP(.NET)? Preferably with ActivePDF WebGrabber

My company purchased ActivePDF WebGrabber a couple of years ago to convert a classic ASP created HTML page into a PDF form. The only drawback with the tool that we continually run into is that the outputted HTML links are not hot. Are there any tools that do include hot-links within the HTML to PDF output?
According to the ActivePDF FAQ for Does WebGrabber convert hyperlinks into usable links in the output PDF?, the answer is no. There is a phrase confusing me at the end of the answer:
"To implement links in the final PDF,
the application would search for links
prior to the Postscript generation,
and append them once the PDF has been
generated using Toolkit."
Does that mean this is how to achieve it, or is this their theoretical but not tested solution? If this is the solution, has anyone done this that might be able to post some sample (pseudo-)code?
Edit: I should mention that we're open to a different tool, and we need it to be accessible via classic ASP and ASP.NET. I would prefer a solution in which the links are automatically hot-linked during PDF generation.
Looks like you can do it with the activepdf toolkit after the pdf is generated. I think this is what they are referring to.
Use the AddHyperlink function on the resultant pdf
AddHyperlink instructs Toolkit to add
a hyperlink in the current output file
that connects to a specified URL.
When clicked, the URL opens in a new
browser window.
edit
It would be easier to get a tool that actually does this here are some links
Open Source HTML to PDF Renderer with Full CSS Support
https://stackoverflow.com/questions/3178448/list-of-html-to-pdf-converters
In the old days, activePDF Server was the engine behind activePDF WebGrabber. activePDF Server is a Print-to-PDF program (hence the reference to Postscript) so the links were not live.
Beginning with the WebGrabber 2009 release, the dependancy on Server was removed and WebGrabber will now (versions 2009 & 2010) output intelligent PDFs that include hot-links within the HTML to PDF output.
If you can call into a web service then try the PDF Conversion Services. We are currently looking for beta testers for the html to pdf bit, just drop a line via the contact page.
I know it is an old question, but nowadays it should be sufficient to use
converter.PreserveLinks = true;
Where converter is a WebGrabber instance.

Relative Links in PDF

Need some advice on what course of action to take next.
Have written an ASP.Net application. Part of the application deals with being able to view PDFs. The initial PDF viewed acts as an index to access other PDF documents. You click a link in the Index PDF and it jumps to another PDF file. Legal documents, agreements, etc.
This scenario works on some computers and on others it doesn't. I managed to figure out what the problem was. On some of the computers the initial Index PDF was being hosted within the browser and on some other computers it was actually jumping out of the browser and directly into Adobe Acrobat. As soon as the PDF jumps out of the browser and into Acrobat the relative links in the Index PDF stop working because it is hosted client side via Acrobat but the additional PDFs it is trying to access are on the server.
I figured out why some computers stay in browser and why some jump out. There is an option within Acrobat itself that determines this behavior. It is under Edit--> Preferences ----> Display PDF in Browser.
I am in a jam because I am not in control of the PDF documents themselves and how they are written, and I obviously have no control over the options selected in Acrobat on each and every computer. My problem is also compounded by the fact that our firm has just recently purchased a new PDF reader called Nuance that will be pushed out firm wide soon and I don't think it even has the option to have PDFs hosted in browser.
I can get what I need to work if I create the index in HTML, but the problem is I don't write the Indexes and the people who do are not trained in HTML. I can get the people who write the indexes to change from relative links to absolute links, but then I run into the problem of what if we change where we are hosting the PDF files? All the links will break again? I think we are stuck with relative URLs, but how can I make it work?
I am thinking about maybe hosting the PDFs within Silverlight?
Looking for any thoughts or ideas?
Thanks.
Silverlight isn't going to help you here.
The solution really is in finding a better way to create the index document. Just how sophisticated is the index document content anyway?
If you don't want to have to train the authors of these indexes in HTML then can you provide them with a simple tool that they can use to describe the content. You could then have code server side to generate the HTML (even PDF) dynamically.
What you need is a simple redirector ASPX page whose URLs you can use in the PDF documents. Put the paths of the PDFs in a database. Give an ID for each PDF. The ASPX page should accept the ID as a parameter, do a lookup on the database, and response.redirect to the current location of the PDF. You can use URLs based on this ASPX page in the PDFs. If you keep database up to date, then the links in the PDF documents will always lead to the correct location.
In the Database
http://someserver/somepath/abc.pdf
ttp://anotherserver/apath/sdf.pdf
Links in the PDF documents
http://yoursite.com/pdf_redirect.aspx?id=1
http://yoursite.com/pdf_redirect.aspx?id=2

Free PDF viewers in ASP.net

I have many PDF documents in binary format which is in the SQL Server 2008 database. I have a gridview in my ASP.net page. When a user clicks on any ID column of the record I need to open the pdf in the browser.
Are there any free PDF viewer controls out there? How can I convert the binary PDF file and display as PDF in the browser.
Thanks
Just return the data to the client with a Content-Type of application/pdf. The client will open it in Adobe Reader or whatever PDF viewer is installed.
If you want a consistent experience without wondering how the user's browser will choose to handle the file (i.e. display it inline, launch Acrobat, or try to save it, etc)...
Google has made its own web-based PDF viewer available for free for embedding. You might use the iframe version in your website.
(This is a sample I created using their web viewer. They make available zoom, thumbnail and page controls - enough to get around the documents easily)
You will have to make an ASP.NET page that delivers the PDF binary stream, then give Google's viewer the URL of that page.
To stream a PDF through an ASPX page you'll want to Google and search for articles like these :
http://support.microsoft.com/default.aspx?scid=kb;en-us;307603
http://support.microsoft.com/default.aspx?scid=kb;en-us;326502
etc.
Basically it's about HTTP and manipulating the MIME type, page headers, etc and writing binary data to the Response stream using available ASP.NET mechanisms.
It might be worthwhile to post a separate question specifically about streaming PDF data through an ASPX page because the current question can be construed as a two-part question or being more oriented toward PDF viewers.
When using modern Webbrowser (with HTML5 Canvas support) you can try PDFJS library (https://mozilla.github.io/pdf.js/)

flex - check image dimensions before upload using filereference

In my Flex application, I use a FileReferenceList that the user can populate with multiple files using fileList.browse() before upload.
I check each file's size and use fileList[i].upload() to upload to my server, this works fine.
I have a suspicion that this is not possible, but before upload I would like to convert each FileReference into an Image in order to check it lies within certain dimension tolerances.
I realise I can do this server side, but ideally I would like the check to appear on both client and server. Can anyone offer any help?
Thanks!
Take a look at this post at the Yahoo! Flash Blog. Flash 10 lets you work with images locally. They give a nice example with code of how you can process FileReference objects, specifically image files.

ASP.net: Display PDF in a asp.net web page

User click on a link button and it will direct them to a url that is dynmaically generated which a pdf file. The browser will prompt the user to either save or open it.
I want to know if it is possible to downlaod the pdf file to the server then show the pdf file in the asp.net web page. When i google on this question, 99% of top link are some third party component. Is it a way to do this without purchase any 3rd party component?
thank
I use itextsharp, its a free open source c# port of the java itext library.
Makes generating dynamic pdfs in asp.net a breeze and there is lots of documentation/examples floating around.
I don't think that you'll have much luck without a 3rd party component. First, the issue isn't showing the PDF, it is generating it. For that, you'll need a library to help. Rolling one yourself would not be cheaper unless you have an enormous amount of unpaid time on your hands.
With respect to third-party controls, I recommend and use DynamicPDF from CeTe.
Yes there is a way to do this without a 3rd party tool, but it involves coding a PDF-to-html translator.
If this is something for a business, the RoI for the 3rd party control is that you don't have to spend hundreds of hours coding & testing this component, when you could buy one for just a few hundred dollars.
Now, an alternative is to code a page which displays the data in the same way which the PDF file generates it (this could actually be handled by RDLC). So that when the user clicks the link button, they are taken to this display page, from which they can download the PDF version if they want a local copy.
Regardless of how you generate the PDF, I have found a better user experience if you open the PDF in an IFRAME instead of the full browser window. You can give users instructions and maintain the browser navigation.
I think what you want to do is by going to: http://my_site.com/generate-pdf.aspx?=someId
this should in fact just show the PDF file?
What you need to do is change the Response type.
See here for how to do this with images.
Look up the Content-Disposition HTTP header. You can send back a value that requests the content be displayed inline instead of downloaded.

Resources