[BUG] [PROPOSAL] [QUESTION] ์ค ํ๋๋ฅผ ๋ฌธ์ ์ ์ ๋์ด๋ก ๋ถ์ด์ญ์์ค.
@kurianic ๋ , ์๋ ์์ ๋ ํตํฉ ๋ฌธ์ A์ B์ ๋ชจ๋ ์ํธ๋ฅผ ์ฝ๊ณ ์ ํตํฉ ๋ฌธ์ C์ ๋ณต์ฌํฉ๋๋ค. A์ B์ ๊ฐ์ ์ด๋ฆ์ ์ํธ๊ฐ ํฌํจ๋์ด ์์ง ์์์ง ํ์ธํ์ญ์์ค.
// Load the workbooks to merge in a collection.
// This example is assuming they're stored in the Laravel storage folder.
$workbooks = collect([
'workbookA.xlsx',
'workbookB.xlsx',
])->map(function ($filename) {
return Excel::load(storage_path($filename));
});
// Create merged workbook
$workbookC = Excel::create('workbookC', function ($excel) use ($workbooks) {
// For each workbook to be merged
$workbooks->each(function ($workbook) use ($excel) {
// Get all the sheets
collect($workbook->getAllSheets())->each(function ($sheet) use ($excel) {
// And add them to the merged workbook
$excel->addExternalSheet($sheet);
});
});
})->save(); // save merged workbook to storage/exports/workbookC.xlsx
@stephanecoinon ์๋ ํ์ธ์, ์ค๋ณต๋ ์ด๋ฆ์ ๋ฐฉ์งํ๊ธฐ ์ํด ๋์ผํ ์ํธ๋ฅผ ์ฌ๋ฌ ๋ฒ ์ถ๊ฐํ๊ณ ์ถ์ต๋๋ค. $sheet->setTitle์ ํธ์ถํ์ต๋๋ค. ํ์ง๋ง "์ํธ๊ฐ ์กด์ฌํ์ง ์์ต๋๋ค."๋ผ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. setTitle ์งํ์ addExternalSheet๊ฐ ํธ์ถ๋ ๋.
$sheet_original->setTitle("SHEET ".$i);
$sheets[$i] = $sheet_original;
$sheets[$i]->cell('I64', function($cell) use($i) { $cell->setValue($i); });
$excel->addExternalSheet($sheets[$i] );
@sarpkaya-xx addSheet()
์๋:
Excel::create('workbook', function ($excel) {
// Create first "original" sheet
$original = $excel->sheet('Sheet 1', function ($sheet) {
$sheet->fromArray([
['foo' => 'bar']
]);
});
// Copy the first sheet 4 times
for ($sheetCount = 2; $sheetCount <= 5; $sheetCount++) {
$copy = $original->getSheet()->copy();
$copy->setTitle("Sheet {$sheetCount}");
$excel->addSheet($copy);
}
})->save();
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@sarpkaya-xx
addSheet()
์๋: