lekoala / silverstripe-excel-import-export Goto Github PK
View Code? Open in Web Editor NEWReplace CSV with Excel in SilverStripe
License: MIT License
Replace CSV with Excel in SilverStripe
License: MIT License
There's an issue in PHP < 8 when integer zero (0) is compared to a string (in this case: "yes").
It always results true, which is incorrect. This causes importing all values with int 0 from XLS file and sets them TRUE.
https://www.php.net/manual/en/language.operators.comparison.php - look at the "Warning" section.
Problem is on:
I think best way is to compare string with string so instead of
if ($val == 'yes') {
use:
if ((string) $val == 'yes') {
this fixes issue, and imports 0/false values properly.
Please upgrade this module so that it installs inside vendor folder as described here -> https://docs.silverstripe.org/en/4/getting_started/directory_structure/#module_structure
Version: 3.0.0
SS version: 5.1.0
The new v3 version currently doesn't work for me. I'm getting this error
E_WARNING: Trying to access array offset on value of type int {"code":2,"message":"Trying to access array offset on value of type int","file":".../vendor/lekoala/silverstripe-excel-import-export/src/ExcelGridFieldExportButton.php","line":337} []
It seems like it's doing some sanitization there and expects $value to be array but it isn't
// @link https://owasp.org/www-community/attacks/CSV_Injection
// [SS-2017-007] Sanitise XLS executable column values with a leading tab
if ($sanitize) {
// If we have only one char we can make it simpler
if ($sanitize_xls_chars_len === 1) {
if ($value && $value[0] === $sanitize_xls_chars) {
$value = "\t" . $value;
}
} else {
if (preg_match('/^[' . $sanitize_xls_chars . '].*/', $value ?? '')) {
$value = "\t" . $value;
}
}
}
The $value
is being set in line 314 $value = $gridField->getDataFieldValue($item, $columnSource);
where $columnSource
is ID
(it's safe to assume it'll be present in any type of object) and it's returning 1, which is probably the ID of the first record, but not array.
When calling the SpreadCompat read method while uploading an spreadsheet (in the ModelAdmin) the method ensureExtension
causes the fileextension to be forced to an tmp file. This results in the file to be unfindable as the tmp file doesn't have an extension.
Is the forced extension required or could it be omitted?
public static function read(
string $filename,
...$opts
): Generator {
$ext = $opts['extension'] ?? null;
if ($ext) {
// Errors on tmp files without an extension.
// $filename = self::ensureExtension($filename, $ext);
}
return static::getAdapterForFile($filename, $ext)->readFile($filename, ...$opts);
}
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.