Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed,Upgrade from box/spout:v3 to openspout/openspout:v3 #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
`Easy Excel`是一个基于 <a href="https://github.com/box/spout" target="_blank">box/spout</a> 封装的Excel读写工具,可以帮助开发者更快速更轻松地读写Excel文件,
并且无论读取多大的文件只需占用极少的内存。


由于box/spout 已经更新为 /openspout/openspout 所以再次更新

> 由于`box/spout`只支持读写`xlsx`、`csv`、`ods`等类型文件,所以本项目目前也仅支持读写这三种类型的文件。


Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"require": {
"php": ">=7.1.0",
"box/spout": "~3",
"openspout/openspout": "~v3.7.4",
"league/flysystem": "~1|~2|~3"
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions src/Contracts/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Dcat\EasyExcel\Contracts;

use Box\Spout\Common\Entity\Style\Style;
use OpenSpout\Common\Entity\Style\Style;

interface Exporter extends Excel
{
Expand Down Expand Up @@ -54,7 +54,7 @@ public function store(string $filePath, array $diskConfig = []);
/**
* @return string
*
* @throws \Box\Spout\Common\Exception\IOException
* @throws \OpenSpout\Common\Exception\IOException
*/
public function raw();
}
4 changes: 2 additions & 2 deletions src/Contracts/Exporters/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Dcat\EasyExcel\Contracts\Exporters;

use Box\Spout\Common\Entity\Row;
use Box\Spout\Common\Entity\Style\Style;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Entity\Style\Style;

interface Sheet
{
Expand Down
4 changes: 2 additions & 2 deletions src/Contracts/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Dcat\EasyExcel\Contracts;

use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Exception\UnsupportedTypeException;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Common\Exception\UnsupportedTypeException;
use Dcat\EasyExcel\Support\SheetCollection;
use League\Flysystem\FileNotFoundException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Dcat\EasyExcel\Contracts;

use Box\Spout\Reader\SheetInterface;
use OpenSpout\Reader\SheetInterface;
use Dcat\EasyExcel\Support\SheetCollection;

interface Sheet
Expand Down
2 changes: 1 addition & 1 deletion src/Excel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Dcat\EasyExcel;

use Box\Spout\Common\Type;
use OpenSpout\Common\Type;
use Dcat\EasyExcel\Exporters\Exporter;
use Dcat\EasyExcel\Exporters\Sheet;
use Dcat\EasyExcel\Importers\Importer;
Expand Down
16 changes: 8 additions & 8 deletions src/Exporters/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Dcat\EasyExcel\Exporters;

use Box\Spout\Common\Entity\Style\Style;
use Box\Spout\Writer\WriterInterface;
use OpenSpout\Common\Entity\Style\Style;
use OpenSpout\Writer\WriterInterface;
use Dcat\EasyExcel\Contracts;
use Dcat\EasyExcel\Spout\WriterFactory;
use Dcat\EasyExcel\Support\Traits\Macroable;
Expand Down Expand Up @@ -137,7 +137,7 @@ public function chunk($callbacks)
public function download(string $fileName)
{
try {
/* @var \Box\Spout\Writer\WriterInterface $writer */
/* @var \OpenSpout\Writer\WriterInterface $writer */
$writer = $this->makeWriter($fileName);

$writer->openToBrowser($this->prepareFileName($fileName));
Expand All @@ -159,7 +159,7 @@ public function download(string $fileName)
* @param array $diskConfig
* @return bool
*
* @throws \Box\Spout\Common\Exception\IOException
* @throws \OpenSpout\Common\Exception\IOException
*/
public function store(string $filePath, array $diskConfig = [])
{
Expand Down Expand Up @@ -187,12 +187,12 @@ public function store(string $filePath, array $diskConfig = [])
/**
* @return string
*
* @throws \Box\Spout\Common\Exception\IOException
* @throws \OpenSpout\Common\Exception\IOException
*/
public function raw()
{
try {
/* @var \Box\Spout\Writer\WriterInterface $writer */
/* @var \OpenSpout\Writer\WriterInterface $writer */
$writer = $this->makeWriter();

ob_start();
Expand All @@ -213,11 +213,11 @@ public function raw()
* @param string $filePath
* @return bool
*
* @throws \Box\Spout\Common\Exception\IOException
* @throws \OpenSpout\Common\Exception\IOException
*/
protected function storeInLocal(string $filePath)
{
/* @var \Box\Spout\Writer\WriterInterface $writer */
/* @var \OpenSpout\Writer\WriterInterface $writer */
$writer = $this->makeWriter($filePath);

$writer->openToFile($filePath);
Expand Down
4 changes: 2 additions & 2 deletions src/Exporters/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Dcat\EasyExcel\Exporters;

use Box\Spout\Common\Entity\Row;
use Box\Spout\Common\Entity\Style\Style;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Entity\Style\Style;
use Dcat\EasyExcel\Contracts;

class Sheet implements Contracts\Exporters\Sheet
Expand Down
30 changes: 15 additions & 15 deletions src/Exporters/WriteSheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Dcat\EasyExcel\Exporters;

use Box\Spout\Common\Entity\Row;
use Box\Spout\Common\Entity\Style\Style;
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
use Box\Spout\Writer\CSV\Writer as CsvWriter;
use Box\Spout\Writer\WriterInterface;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Entity\Style\Style;
use OpenSpout\Writer\Common\Creator\WriterEntityFactory;
use OpenSpout\Writer\CSV\Writer as CsvWriter;
use OpenSpout\Writer\WriterInterface;
use Dcat\EasyExcel\Contracts;
use Dcat\EasyExcel\Excel;
use Dcat\EasyExcel\Support\Arr;
Expand All @@ -26,8 +26,8 @@ trait WriteSheet
* @param WriterInterface $writer
* @return WriterInterface
*
* @throws \Box\Spout\Common\Exception\IOException
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException
* @throws \OpenSpout\Common\Exception\IOException
* @throws \OpenSpout\Writer\Exception\WriterNotOpenedException
*/
protected function writeSheets(WriterInterface $writer)
{
Expand Down Expand Up @@ -65,8 +65,8 @@ protected function writeSheets(WriterInterface $writer)
* @param array $rows
* @param Contracts\Exporters\Sheet $sheet
*
* @throws \Box\Spout\Common\Exception\IOException
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException
* @throws \OpenSpout\Common\Exception\IOException
* @throws \OpenSpout\Writer\Exception\WriterNotOpenedException
*/
protected function writeRowsFromArray(WriterInterface $writer, $index, array &$rows, Contracts\Exporters\Sheet $sheet)
{
Expand All @@ -86,8 +86,8 @@ protected function writeRowsFromArray(WriterInterface $writer, $index, array &$r
* @param Generator $generator
* @param Contracts\Exporters\Sheet $sheet
*
* @throws \Box\Spout\Common\Exception\IOException
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException
* @throws \OpenSpout\Common\Exception\IOException
* @throws \OpenSpout\Writer\Exception\WriterNotOpenedException
*/
protected function writeRowsFromGenerator(WriterInterface $writer, $index, Generator $generator, Contracts\Exporters\Sheet $sheet)
{
Expand All @@ -107,8 +107,8 @@ protected function writeRowsFromGenerator(WriterInterface $writer, $index, Gener
* @param array $item
* @param Contracts\Exporters\Sheet $sheet
*
* @throws \Box\Spout\Common\Exception\IOException
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException
* @throws \OpenSpout\Common\Exception\IOException
* @throws \OpenSpout\Writer\Exception\WriterNotOpenedException
*/
protected function writeRow(WriterInterface $writer, array &$item, Contracts\Exporters\Sheet $sheet)
{
Expand All @@ -132,8 +132,8 @@ protected function writeRow(WriterInterface $writer, array &$item, Contracts\Exp
* @param Contracts\Exporters\Sheet $sheet
* @param array $firstRow
*
* @throws \Box\Spout\Common\Exception\IOException
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException
* @throws \OpenSpout\Common\Exception\IOException
* @throws \OpenSpout\Writer\Exception\WriterNotOpenedException
*/
protected function writeHeadings(WriterInterface $writer, Contracts\Exporters\Sheet $sheet, array $firstRow)
{
Expand Down
20 changes: 10 additions & 10 deletions src/Importers/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Dcat\EasyExcel\Importers;

use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Exception\UnsupportedTypeException;
use Box\Spout\Reader\Common\Creator\ReaderFactory;
use Box\Spout\Reader\ReaderInterface;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Common\Exception\UnsupportedTypeException;
use OpenSpout\Reader\Common\Creator\ReaderFactory;
use OpenSpout\Reader\ReaderInterface;
use Dcat\EasyExcel\Contracts;
use Dcat\EasyExcel\Contracts\Sheet as SheetInterface;
use Dcat\EasyExcel\Support\SheetCollection;
Expand Down Expand Up @@ -194,10 +194,10 @@ public function active(): Contracts\Sheet
}

/**
* @param \Box\Spout\Reader\ReaderInterface $reader
* @param \OpenSpout\Reader\ReaderInterface $reader
* @return \Generator
*
* @throws \Box\Spout\Reader\Exception\ReaderNotOpenedException
* @throws \OpenSpout\Reader\Exception\ReaderNotOpenedException
*/
protected function readSheets(ReaderInterface $reader)
{
Expand All @@ -210,10 +210,10 @@ protected function readSheets(ReaderInterface $reader)

/**
* @param string|UploadedFile $path
* @return \Box\Spout\Reader\ReaderInterface
* @return \OpenSpout\Reader\ReaderInterface
*
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
* @throws \Box\Spout\Common\Exception\IOException
* @throws \OpenSpout\Common\Exception\UnsupportedTypeException
* @throws \OpenSpout\Common\Exception\IOException
*/
protected function makeReader($path)
{
Expand All @@ -223,7 +223,7 @@ protected function makeReader($path)
$path = $path->getRealPath();
}

/* @var \Box\Spout\Reader\ReaderInterface $reader */
/* @var \OpenSpout\Reader\ReaderInterface $reader */
if ($this->type || $extension) {
$reader = ReaderFactory::createFromType($this->type ?: $extension);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Importers/NullSheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Dcat\EasyExcel\Importers;

use Box\Spout\Reader\SheetInterface;
use OpenSpout\Reader\SheetInterface;
use Dcat\EasyExcel\Contracts;
use Dcat\EasyExcel\Support\SheetCollection;

Expand Down
4 changes: 2 additions & 2 deletions src/Importers/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Dcat\EasyExcel\Importers;

use Box\Spout\Common\Entity\Row;
use Box\Spout\Reader\SheetInterface;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Reader\SheetInterface;
use Dcat\EasyExcel\Contracts;
use Dcat\EasyExcel\Support\Arr;
use Dcat\EasyExcel\Support\SheetCollection;
Expand Down
2 changes: 1 addition & 1 deletion src/Spout/GlobalFunctionsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Dcat\EasyExcel\Spout;

use Box\Spout\Common\Helper\GlobalFunctionsHelper as Helper;
use OpenSpout\Common\Helper\GlobalFunctionsHelper as Helper;

class GlobalFunctionsHelper extends Helper
{
Expand Down
30 changes: 15 additions & 15 deletions src/Spout/WriterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

namespace Dcat\EasyExcel\Spout;

use Box\Spout\Common\Creator\HelperFactory;
use Box\Spout\Common\Exception\UnsupportedTypeException;
use Box\Spout\Common\Type;
use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
use Box\Spout\Writer\CSV\Manager\OptionsManager as CSVOptionsManager;
use Box\Spout\Writer\ODS\Creator\HelperFactory as ODSHelperFactory;
use Box\Spout\Writer\ODS\Creator\ManagerFactory as ODSManagerFactory;
use Box\Spout\Writer\ODS\Manager\OptionsManager as ODSOptionsManager;
use Box\Spout\Writer\WriterInterface;
use Box\Spout\Writer\XLSX\Creator\HelperFactory as XLSXHelperFactory;
use Box\Spout\Writer\XLSX\Creator\ManagerFactory as XLSXManagerFactory;
use Box\Spout\Writer\XLSX\Manager\OptionsManager as XLSXOptionsManager;
use OpenSpout\Common\Creator\HelperFactory;
use OpenSpout\Common\Exception\UnsupportedTypeException;
use OpenSpout\Common\Type;
use OpenSpout\Writer\Common\Creator\InternalEntityFactory;
use OpenSpout\Writer\Common\Creator\Style\StyleBuilder;
use OpenSpout\Writer\CSV\Manager\OptionsManager as CSVOptionsManager;
use OpenSpout\Writer\ODS\Creator\HelperFactory as ODSHelperFactory;
use OpenSpout\Writer\ODS\Creator\ManagerFactory as ODSManagerFactory;
use OpenSpout\Writer\ODS\Manager\OptionsManager as ODSOptionsManager;
use OpenSpout\Writer\WriterInterface;
use OpenSpout\Writer\XLSX\Creator\HelperFactory as XLSXHelperFactory;
use OpenSpout\Writer\XLSX\Creator\ManagerFactory as XLSXManagerFactory;
use OpenSpout\Writer\XLSX\Manager\OptionsManager as XLSXOptionsManager;
use Dcat\EasyExcel\Spout\Writers\CSVWriter;
use Dcat\EasyExcel\Spout\Writers\ODSWriter;
use Dcat\EasyExcel\Spout\Writers\XLSXWriter;
Expand All @@ -27,7 +27,7 @@ class WriterFactory
* @param string $path The path to the spreadsheet file. Supported extensions are .csv,.ods and .xlsx
* @return WriterInterface
*
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
* @throws \OpenSpout\Common\Exception\UnsupportedTypeException
*/
public static function createFromFile(string $path)
{
Expand All @@ -42,7 +42,7 @@ public static function createFromFile(string $path)
* @param string $writerType Type of the writer to instantiate
* @return WriterInterface
*
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
* @throws \OpenSpout\Common\Exception\UnsupportedTypeException
*/
public static function createFromType($writerType)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Spout/Writers/CSVWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Dcat\EasyExcel\Spout\Writers;

use Box\Spout\Writer\CSV\Writer;
use OpenSpout\Writer\CSV\Writer;

class CSVWriter extends Writer
{
Expand Down
2 changes: 1 addition & 1 deletion src/Spout/Writers/ODSWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Dcat\EasyExcel\Spout\Writers;

use Box\Spout\Writer\ODS\Writer;
use OpenSpout\Writer\ODS\Writer;

class ODSWriter extends Writer
{
Expand Down
2 changes: 1 addition & 1 deletion src/Spout/Writers/XLSXWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Dcat\EasyExcel\Spout\Writers;

use Box\Spout\Writer\XLSX\Writer;
use OpenSpout\Writer\XLSX\Writer;

class XLSXWriter extends Writer
{
Expand Down
10 changes: 5 additions & 5 deletions src/Traits/Excel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Dcat\EasyExcel\Traits;

use Box\Spout\Common\Entity\Style\Style;
use Box\Spout\Common\Type;
use Box\Spout\Reader\CSV\Reader as CSVReader;
use Box\Spout\Writer\CSV\Writer as CSVWriter;
use OpenSpout\Common\Entity\Style\Style;
use OpenSpout\Common\Type;
use OpenSpout\Reader\CSV\Reader as CSVReader;
use OpenSpout\Writer\CSV\Writer as CSVWriter;
use Dcat\EasyExcel\Support\SheetCollection;
use Illuminate\Contracts\Filesystem\Filesystem as LaravelFilesystem;
use Illuminate\Support\Facades\Storage;
Expand Down Expand Up @@ -196,7 +196,7 @@ public function configureCsv(
}

/**
* @param \Box\Spout\Reader\ReaderInterface|\Box\Spout\Writer\WriterInterface $readerOrWriter
* @param \OpenSpout\Reader\ReaderInterface|\OpenSpout\Writer\WriterInterface $readerOrWriter
*/
protected function configure(&$readerOrWriter)
{
Expand Down
Loading