Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php open excel file in browser

Tags:

php

com

how to open excel file in browser ,

i dont want some thing like force download dialog ,

i want to open excel in browser somthing like in gmail when u click the excel file in the inbox, it will show browser itself,

same like , how to do in php.

like image 901
Bharanikumar Avatar asked Oct 05 '10 06:10

Bharanikumar


People also ask

How do I get Excel to open in browser instead of app?

Select the file in OneDrive or SharePoint. Select the More icon. , then select Open. Select Open in (app) (such as Open in Word).

How open PHP file in Excel?

Loading a Spreadsheet File $inputFileName = './sampleData/example1. xls'; /** Load $inputFileName to a Spreadsheet Object **/ $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName); See samples/Reader/01_Simple_file_reader_using_IOFactory. php for a working example of this code.

Can we read Excel file in PHP?

PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc. In this tutorial, we are going learn how to read and write the xlsx file. You can integrate it with your database if you need.


1 Answers

Using PHPExcel:

include 'PHPExcel/IOFactory.php';
$inputFileType = 'Excel5';
$inputFileName = 'MyExcelFile.xls';

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');
exit;

EDIT

If your Excel file is Excel 2007 (xlsx) or later rather than Excel 2003 (xls) or earlier

include 'PHPExcel/IOFactory.php';
$inputFileType = 'Excel2007';
$inputFileName = 'MyExcelFile.xlsx';

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');
exit;
like image 199
Mark Baker Avatar answered Oct 17 '22 17:10

Mark Baker