1
votes

I'm using Google Docs Viewer that is embedded in iFrame.

It's showing .xls, .xml, .csv files fine, but when trying to view .xlsx file it fails (as shown in screenshot)Not showing data

I specify two links for testing:

http://docs.google.com/viewer?url=http%3A%2F%2F______.__%2Fuploads%2FBook1.xlsx&embedded=true

http://docs.google.com/viewer?url=http://justinas.tk/uploads/Book1.xlsx&embedded=true

iFrames are appended using this jQuery

preview.append('<iframe src="http://docs.google.com/viewer?url=' + encodeURIComponent('http://______.__/uploads/Book1.xlsx') + '&embedded=true"></iframe>');
preview.append('<iframe src="http://docs.google.com/viewer?url=' + 'http://______.__/uploads/Book1.xlsx' + '&embedded=true"></iframe>');

As specified here Google Docs Viewer support .xlsx files. What is wrong here?

1

1 Answers

1
votes

I have done some tests with mime-type of word documents .docx

File saved with King Soft: ks.docx
File saved with LibreOffice: xj.docx
File saved with MS Word: word1.docx

word1.docx:application/vnd.openxmlformats-officedocument.wordprocessingml.document; charset=binary
ks.docx:application/zip; charset=binary
xj.docx:application/zip; charset=binary

PHP script to get these results:

<?php
$finfo = finfo_open(FILEINFO_MIME);
echo 'word1.docx: ' . finfo_file($finfo, 'word1.docx') . '<br/>';
echo 'ks.docx: ' . finfo_file($finfo, 'ks.docx') . '<br/>';
echo 'xj.docx: ' . finfo_file($finfo, 'xj.docx');

As you can see it's mime-type that is wrong from other non-ms-word programs.