GomuGomuNoRocket
GomuGomuNoRocket

Reputation: 839

Can preview a XLSX or XLS in browser?

I have a MVC ActionResult controller that download the file.

If the file is PDF then using this JS code

var $obj = $('<object>');
$obj.attr("type", "application/pdf");
$obj.attr("data", myurl);                            
$("#id").append($obj);

Then I can preview the PDF in my app.

I want something similar for XLSX or XLS files.

If I hit the URL I get the file but I cannot display it.

I tried with

<iframe src="https://docs.google.com/gview?url=myurl"></iframe>

but doesn't work.

Any ideas?

Upvotes: 10

Views: 12633

Answers (2)

K J
K J

Reputation: 11857

If you have an online URL ending with.xlsx, Google and Microsoft provide online viewers.

Microsoft should work better with their proprietary XLSX components: https://view.officeapps.live.com/op/view.aspx?src=https://www.sqa.org.uk/sqa/files_ccc/progression-2023-tables.xlsx view.officeapps.live.com screenshot

Google's more basic viewer: https://docs.google.com/gview?url=https://www.sqa.org.uk/sqa/files_ccc/progression-2023-tables.xlsx docs.google.com screenshot

Upvotes: 3

tiriana
tiriana

Reputation: 668

While I was unable to preview these files in the browser, I developed a small script that monitors my Downloads directory for new XLS files, automatically closes LibreOffice Calc (if open), and reopens it with the newly downloaded file: https://gist.github.com/tiriana/6f9b8fa7861592e3ac0c2271de502f46#file-watch_and_open-sh

Upvotes: 0

Related Questions