Excel to php array online

Главная

Инструменты

Excel в PHP-массив онлайн

14.12.2017

24111

1 комментарий

В закладки

20

5

Загрузите файл Excel чтобы перевести его в массив PHP, JS, JSON.

Перетащите сюда файл xls, xlsx, csv
или
выберите файл

Номер листа в excel Удалить пустые строки
Начать со строки Удалить пустые колонки
Кодировка файла Добавить ключи в массив

PHP массив

JS массив

JSON

SQL

14.12.2017, обновлено 05.12.2022

24111

В закладки

20

5

Комментарии 1

Farrux Xalmuratov
Farrux Xalmuratov

15 января 2022 в 19:16

+2

Wy not working convertor?

Ответить

  • Скопировать ссылку
  • Пожаловаться

Авторизуйтесь, чтобы добавить комментарий.

The tool helps you convert Excel file content (.xlsx or csv format) to php content, supports beautifying php content after conversion

What can I do with the Excel to Php Array converter?

Convert excel file content to .php format

You can select the .xlsx file from your computer.

Download the PHP file after conversion.

There is also a widget to beautify PHP content

How to use Excel to Php Array converter?

This tool is very easy to use, you only need to operate through 2 steps to be able to complete and get the desired results.

Step 1: Select the .xlsx file from the device.

Step 2: Click the «Convert Excel to Php Array» button, then download the .php file to use or copy the content to use.

Why use Sita’s Excel to Php Array converter?

This tool is very easy to use, simple operation, friendly interface.

No need to install any other software or utilities.

Compatible with any browser, any operating system, any device.

All information is encrypted, we do not store your data.

I have a big excel file that looks like this:

enter image description here

I would like to put each row into an array.

Is this possible to access the first row’s order id like this?

$result[0][2] // returns 7432

Assuming the actual first row that gives prefix for the columns’ name is not present.

How could I do that?

Alireza Fallah's user avatar

asked Nov 17, 2011 at 16:17

Karem's user avatar

May be my answer is too simple (for one time work only), but I use the CONCATENATE «Function» in excell.
The last cell on each row will have concatenation function, like this:

=CONCATENATE("['";A2;"'=>['data1' => '";B2;"', 'data2' => '";C2;"'],")

where:

column "A" is ID of something;
column "B" is first characteristic;
column "C" is second characteristic;
etc.

Then just copy and paste function results to Your script or config file, and do not forget the first and the last bracket.

answered Apr 17, 2015 at 19:34

Rostyslav Pylypenko's user avatar

1

This works for me:

$content = file_get_contents($your_file_path); 
$lines = array_map("rtrim", explode("n", $content));

Lars Ebert's user avatar

Lars Ebert

3,4472 gold badges22 silver badges44 bronze badges

answered Jul 10, 2015 at 6:19

paulalexandru's user avatar

paulalexandrupaulalexandru

9,1776 gold badges65 silver badges93 bronze badges

Since the PHPExcel library deprecated they’ve released «PhpSpreadsheet»

This will help PhpSpreadsheet

answered Oct 28, 2018 at 10:07

Saed Yousef's user avatar

Saed YousefSaed Yousef

1281 silver badge10 bronze badges

1

@calvinchoy

Created

June 20, 2013 08:46

Star

PHP — excel to array helper function


This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters

Show hidden characters

<?php
/*
|—————————————————————————
| Excel To Array
|—————————————————————————
| Helper function to convert excel sheet to key value array
| Input: path to excel file, set wether excel first row are headers
| Dependencies: PHPExcel.php include needed
*/
function excelToArray($filePath, $header=true){
//Create excel reader after determining the file type
$inputFileName = $filePath;
/** Identify the type of $inputFileName **/
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
/** Create a new Reader of the type that has been identified **/
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
/** Set read type to read cell data onl **/
$objReader->setReadDataOnly(true);
/** Load $inputFileName to a PHPExcel Object **/
$objPHPExcel = $objReader->load($inputFileName);
//Get worksheet and built array with first row as header
$objWorksheet = $objPHPExcel->getActiveSheet();
//excel with first row header, use header as key
if($header){
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$headingsArray = $objWorksheet->rangeToArray(‘A1:’.$highestColumn.‘1’,null, true, true, true);
$headingsArray = $headingsArray[1];
$r = —1;
$namedDataArray = array();
for ($row = 2; $row <= $highestRow; ++$row) {
$dataRow = $objWorksheet->rangeToArray(‘A’.$row.‘:’.$highestColumn.$row,null, true, true, true);
if ((isset($dataRow[$row][‘A’])) && ($dataRow[$row][‘A’] > »)) {
++$r;
foreach($headingsArray as $columnKey => $columnHeading) {
$namedDataArray[$r][$columnHeading] = $dataRow[$row][$columnKey];
}
}
}
}
else{
//excel sheet with no header
$namedDataArray = $objWorksheet->toArray(null,true,true,true);
}
return $namedDataArray;
}
?>

Like this post? Please share to your friends:
  • Excel to pdf net core
  • Excel to pdf library
  • Excel to pdf editor
  • Excel to pdf converter offline
  • Excel to pdf apk