Giter Site home page Giter Site logo

xlsxreader's Introduction

XLSXReader

What it does

XLSXReader is a small PHP class for reading data from Microsoft Excel XLSX (OpenXML) files. There are some much more comprehensive Excel libraries for PHP, but I created this because I was looking for a library that made it as easy as possible to:

  1. Open an Excel file
  2. Get a list of the sheets (names and sheetIds)
  3. Get the data out from a sheet into an array

XLSXReader requires the ZIP extension.

Thanks to Sergey Schuchkin for his SimpleXLSX library that served as the inspiration for XLSXReader. While most of it has been rewritten, some of his code still remains.

Usage

Open an Excel file:

require('XLSXReader.php');
$xlsx = new XLSXReader('sample.xlsx');

Get a list of the sheets:

$sheets = $xlsx->getSheetNames();

Get the data from a sheet:

$data = $xlsx->getSheetData('Sales');

What it doesn't do

There are many things XLSXReader does not aim to do:

  1. Handle sheets with a large amount of data - XLSXReader uses SimpleXML to read the sheet data, so the entire XML file is read into memory when accessing a sheet.
  2. Extract formatting, formulas, comments, headers, footers, properties, or charts
  3. Create or edit Excel files

If you need those capabilities, I would take a look at PHP-Excel.

xlsxreader's People

Contributors

gneustaetter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xlsxreader's Issues

Throws syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM on PHP 5.2

Trying to run on PHP 5.2, generates the following error

Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in xlsxreader.php on line 280

The offending line:

$value = $self::parseRichText($cell->is);

I think this error is because PHP 5.2 doesn't support $stringClassName::methodName() syntax. Wondering, Is there a workaround for this?

Arrays

This is purely a data structure issue, and your taste may vary from mine.

On 113 of the class, you use the sheetId as the array key for the data returned on getSheetNames()

I can see the logic behind it, but when presented with a numeric key array, I don't expect my array to be in order and not start at 0.

Too much white-space in parseRichText() v0.4

The method parseRichText() concatenates all text found in individual text runs with a white-space, i.e. by implode(' ', $value) on line 315 in v0.4.

At least with our XLSX this turns out to be wrong since it adds white-space between differently formatted text elements in one cell and by that doubling existing white-space. Changing it to implode('', $value) solved the problem.

__construct isData option

I think it would be great if this class has option that oryginal class has - __construct parameter that allows you to tell if you're sending string of filename or sting of file content to compute.

zip->open() returns ZipArchive::ER_NOENT

Before last weekend, I was able to read XLSX files. As of last weekend, any type of XLSX file I try to open returns a ZipArchive::ER_NOENT status code. I've tested two types of XLSX files that were verified by running file test.xlsx in Linux:

  • Microsoft OOXML
  • Microsoft Excel 2007+

Both these files open with LibreOffice Calc.

The line that returns the error is in XLSXReader.php: $status = $this->zip->open($filePath);

Why are neither of my XLSX files reading suddenly?

I've tested the following Zip classes and they all fail when attempting to use ZipArchive::open. It seems the open method uses the zlib library, which seems to use the [libzip](https://libzip.org/) library.

So, it seems the issue is with lib zip.

Error @ line 62

$data = array_map(function($row)
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /opt/lampp/htdocs/dbis/venki/AmBank/XLSXReader-master/sample.php on line 62

Pleae help me to solve

code is as follows

$data = array_map(function($row)
{
$converted = XLSXReader::toUnixTimeStamp($row[0]);
return array($row[0], $converted, date('c', $converted), $row[1]);
}, $xlsx->getSheetData('Dates'));
array_unshift($data, array('Excel Date', 'Unix Timestamp', 'Formatted Date', 'Data'));
array2Table($data);
?>

reply to email as [email protected]

Good Suggest For Dear Author

Hi Dear Gneustaetter. I doubt why not add a composer.json file to your project in order to provide composer service for PHP coder all around the world.
I like your XLSXReader very much so I use it in my project .
But I also use composer to manage code of open source. I have no choice untill a composer.json file be added into the project .
this is my folk :
https://github.com/newlubin/XLSXReader

Hope to hear from U Email: [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.