By Beans on
How to import excel sheet and retrieve the content for storage, am not like to change these excel file to csv file , i came to know that some of class is available for these work (ex:sheet_excel_reader) i search a lot but, i found nothing,could you show me the correct way .....
-- Thanks in advance (:-)
Comments
Use below
Use below link
http://code.google.com/p/php-excel-reader/
After extracting code, you can use this like
require_once 'excel_reader2.php';
$xlsfile = "sampleFile.xls";
$data = new Spreadsheet_Excel_Reader($xlsfile);
//Specify your rows and columns
for ($row = 2; $row < 5; $row++) {
$no = 1;
for ($col = $no; $col <= 21; $col++) {
//this is function define in class
$output[$row][$col] = $data->val($row, $col, $sheet = 0);
}
Vikrant R
Use below
Use below link
http://code.google.com/p/php-excel-reader/
After extracting code, you can use this like
require_once 'excel_reader2.php';
$xlsfile = "sampleFile.xls";
$dataObj = new Spreadsheet_Excel_Reader($xlsfile);
//Specify your rows and columns
for ($row = 0; $row < 10; $row++) {
$no = 1;
for ($col = $no; $col <= 10; $col++) {
//this is function define in class
$output[$row][$col] = $dataObj ->val($row, $col, $sheet = 0);
}
Vikrant R
where we have to past those php-excel-reader code
Thanks for your reply,
You said that we have to extract the code from the above link, where we have to past those php-excel-reader code in to the drupal ..
PHP Excel Reader
This is a class file, You need to keep it in your module and include this file for access this class.
$path = drupal_get_path('module', 'your_module_name'). "/file_name.xls";
$data = new Spreadsheet_Excel_Reader($path);
$numRows = $data->sheets[0]['numRows'];
$numCols = $data->sheets[0]['numCols'];
//Start for loop
for($row = 2; $row <= $numRows; $row++) {
$no = 1;
for ($col = $no; $col <= $numCols; $col++) {
$output[$row][$col] = $data->val($row, $col, $sheet = 0);
}
}
Hope this will help you.
Vikrant R