akeneo-labs / spreadsheet-parser Goto Github PK
View Code? Open in Web Editor NEWFast XLSX parser that spares resources
License: Other
Fast XLSX parser that spares resources
License: Other
The title of the issue says it all :)
Is that possible to do using this library? Thank you.
Packagist does not reflect the merge of #33:
It would be great to configure the Packagist hook on the repo (be careful that you need to configure the user
field as the Packagist maintainer is akeneo
, not akeneo-labs
)
Hi,
I have found an issue reading CSV file from Windows 7 Professional Service Pack 1, Spanish. Method openResource of RowIterator.php class uses getCurrentEncoding which returns "1252" but php recognized "Windows-1252" encoding instead.
I wonder If you could solve this issue soon.
Thank you!
The Archive class deletes the temporary folder when it gets destructed. This means that any class in the library relying on files extracted there should keep a reference to the archive to prevent it from being deleted too early.
I faced this issue when returning the row iterator outside the method holding the Spreadsheet object. As the Archive is currently referenced only by the Spreadsheet, the Archive instance got deleted, deleting the temp folder while the iterator itself was still alive (and not even yet used). I had to read the code of the library to understand why I was getting a PHP warning when opening the worksheet in the iterator.
OptionsResolver::setOptional
is deprecated since Symfony 2.6 and removed in 3.0. It would be great to add support for the new API of the component when available
Is there a way to show formula rather than value from createRowIterator ?
When a cell column with text has a leading apostrophe this apostrophe gets cut off, for example with (place) names this can give problems.
If i search for this issue i find that this is already fixed in PHPExcel, can anyone help me to fix this?
Thanks for making this project!
In the CSV example, $workbook->createRowIterator()
and $workbook->createIterator($iterator) {}
Strict standards: Non-static method Akeneo\Component\SpreadsheetParser\Xlsx\XlsxParser::createRelationshipsLoader() should not be called statically in vendor/akeneo/spreadsheet-parser/src/Xlsx/XlsxParser.php on line 89
Akeneo\Component\SpreadsheetParser\SpreadsheetParser::getSpreadsheetLoader() vendor/akeneo/spreadsheet-parser/src/SpreadsheetParser.php:29
0.0062 304928 4. Akeneo\Component\SpreadsheetParser\SpreadsheetParser::configureLoaders() vendor/akeneo/spreadsheet-parser/src/SpreadsheetParser.php:41
0.0068 312864 5. Akeneo\Component\SpreadsheetParser\Xlsx\XlsxParser::getSpreadsheetLoader() vendor/akeneo/spreadsheet-parser/src/SpreadsheetParser.php:53
You want to contribute and don't know where to start ?
We need help to fix code style issues : https://scrutinizer-ci.com/g/akeneo-labs/spreadsheet-parser/issues/master
Hey there, I'm digging working with this library. We've run into a situation where we want to load XLS files as well. Obviously, it would be quite a bit of code to write a Spreadsheet Loader for XLS files. I'm wondering if you might consider adding a composer dependency for phpexel in order to automatically convert an xls file to xlsx which we can then use the xlsx parser with. Is that something you'd consider?
I hope it can support XLS file. Thank you
don't know why this happen , only get this error messages:
PHP Warning 'yii\base\ErrorException' with message 'unlink(C:\Users\Administrato
r\AppData\Local\Temp\xlsACD3.tmp\xl\sharedStrings.xml): Permission denied'
in G:\yiqing-workspace\cxtx-web\vendor\akeneo\spreadsheet-parser\src\Xlsx\Archiv
e.php:117
Stack trace:
#0 G:\yiqing-workspace\cxtx-web\vendor\akeneo\spreadsheet-parser\src\Xlsx\Archiv
e.php(67): Akeneo\Component\SpreadsheetParser\Xlsx\Archive->deleteTemp()
seems can not delete the temp file created earlier ! I just report this things !
for temp usage i simple make the deleteTemp method return immediately . and manually delete the temp file which created by the Akeneo\Component\SpreadsheetParser\Xlsx\Archive class!
I am using mk-j/PHP_XLSXWriter to generate an xlsx file.
The change that was made in the recent version of PHP_XLSXWriter was to stop using shared string, and to write all strings as inline strings. Switching to inline strings was done on purpose to reduce memory usage when writing gigantic spreadsheets.
But when i now try to import/read this script with the spreadsheet-parser it does not read any values but the nummeric values and al the other columns are shown blank/empty.
An older version of PHP_XLSXWriter using shared strings can be imported.
Can anyone explain what is going wrong and why the columns array empty in de generated array?
I am writing an import script for a large (~135MB/500K rows, 1 sheet) xlsx file. I would like to have a progress bar but obviously that requires knowing the number of rows in the sheet. How can I do that with this library?
I try to read an xlsx file
$workbook = \Akeneo\Component\SpreadsheetParser\SpreadsheetParser::open($file);
$worksheets = $workbook->getWorksheets();
$rowIterator = $workbook->createRowIterator($sheet);
foreach ($rowIterator as $rowIndex => $values) {
but in some files the first row ist not the first in the document.
I can solve the problem by open the files with libreoffice an save them again.
Is there any solution by doing this programatically?
Hi!
Your library is awesome!
I have a small problem though, maybe you can help:
I tested your sample code to parse an excel file and it works perfectly.
But when I try to do something like this:
function extractor_test($path) {
$workbook = SpreadsheetParser::open($path);
$worksheetIndex = $workbook->getWorksheetIndex('Sheet1');
$iterator = $workbook->createRowIterator($worksheetIndex);
return $iterator;
}
foreach (extractor_test($filePath) as $key => $value) {
$counter++;
}
I get this exception: XMLReader::open(): Unable to open source data'
Hi,
I'd like to know if it's possible to parse multiple sheets in an excel file or does the spreadsheet parser only worked on a single worksheet file?
Thanks
If I iterate though the row of a workbook, I will get a miss-match on the number of cells as it doesn't seem to return cells which are blank? I think this is only the case with the last cell of the current row.
it points to a 404
Writer using PhpOffice\PhpSpreadsheet\Writer\Xlsx while want to open file i got this error,
in Psr17Factory.php line 44
at Psr17Factory->createStreamFromFile('')in PsrHttpFactory.php line 115
at PsrHttpFactory->createUploadedFile(object(UploadedFile))in PsrHttpFactory.php line 95
at PsrHttpFactory->getFiles(array('file' => object(UploadedFile)))in PsrHttpFactory.php line 65
at PsrHttpFactory->createRequest(object(Request))in JsonApiFactory.php line 27
at JsonApiFactory->create()in getJsonApiService.php line 12
I have a really large XLSX file (150,000 rows, 16 columns). I receive this file from the company I work for and have no control over its format or features.
Before it gives me the XMLReader::open()
error, it gives me No loader for type
error. I fix this by manually specifying the type as a second parameter like this: $workbook = SpreadsheetParser::open($request->file('spreadsheet'), 'xlsx');
When I attempt to open it I get this error XMLReader::open(): Unable to open source data
. I did some searching and saw this was an issue a while back on issue 22 ( #22 ).
I have tried adding libxml_disable_entity_loader(false)
before SpreadsheetParser::open()
and it still fails.
libxml Version => 2.9.4
What is weird is, that if I open this xlsx file in excel, and then save, and then reattempt the newly saved file it works. Like it somehow fixes an imperfection or something.
I have attached the file in its original format. It errors out. Try opening and saving and then reprocessing and it should work. No idea why. Would like to figure out a way to bypass this added step so I can just process it all in one go from PHP.
Original
SOR_Contractor_Equipment_UXID_Report.xlsx.zip
After I open it with Excel, and go to File->Save->
(rewrites I am assuming).
Resaved_SOR_Contractor_Equipment_UXID_Report.xlsx.zip
P.S. This library is for some reason 4 times faster than box/spout. I originally started with them but it was taking almost 80-90 seconds to parse this file while this library parses it in about 15-20 seconds. On another note, their library can open the file without me having to resave it. I think they use a different opening method though, you use XMLReader::open
and I think they use ZipArchive
.
I have a sentence in a cell which has some bold words. When iterator reads this cell it only takes words before bold (or any other styled i guess) word and omits the rest.
It's possible to get the styles applied to a cell while iterating on the worksheet? The task that I've have at hand is to exclude some rows that contains a specific format (color red / striked text, for instance). I've seen that the styles are used essentially just to return the right type of data when a numeric value is found.
I would like to read first row without createRowIterator interface as first line, in XLSX file, belongs to my database table fields. So I would like to read them first and want to put it in fields array.
I am using your sample code at first level:
use Akeneo\Component\SpreadsheetParser\SpreadsheetParser;
use Akeneo\Component\SpreadsheetParser\Xlsx\XlsxParser;
$workbook = SpreadsheetParser::open('myfile.xlsx');
$myWorksheetIndex = $workbook->getWorksheetIndex('sheet1');
//MY REQUIREMENT
//Here I want to get first row as they will be treated as my table fields.
foreach ($workbook->createRowIterator($myWorksheetIndex) as $rowIndex => $values) {
var_dump($rowIndex, $values);
}
Any help would be appreciated.
Thanks, Sumit
Trying to run validation on a spreadsheet that includes searching for headers that contain a space (" ") or an empty string beyond the final valid header. When the spreadsheet is parsed it doesn't include these headers in the returned list of values.
If they are found within a list of valid rows it is found but trims the value to an empty string ("").
Using this lib to parse my Xlsx and CSV files, works great, but for one file.
Can't give you the file because it's client's property, it's a UTF8 encoded xlsx file (3mb).
and it's always returning me :
Error opening file: Zip archive inconsistent at /srv/api/vendor/akeneo-labs/spreadsheet-parser/src/Xlsx/Archive.php:86
When trying to parse this file, it's a totally normal file, i can open it in numbers / Excel / or spreadsheets reader. The only things that change is this is a file created with an Old Excel ( 1997 or 2003 )
Do you think it's possible that this is the probleme ?
I got this when trying to import excel
ErrorException in Archive.php line 117:
unlink(C:\Windows\Temp\xlsFE42.tmp\xl\sharedStrings.xml): Permission denied
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.