Laravel-excel: ๋‘ ๊ฐœ์˜ xlsx ํŒŒ์ผ์„ ๋ณ‘ํ•ฉํ•˜๊ณ  ๊ฒฐํ•ฉ๋œ ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•ฉ๋‹ˆ๊นŒ?

์— ๋งŒ๋“  2017๋…„ 10์›” 09์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: Maatwebsite/Laravel-Excel

[BUG] [PROPOSAL] [QUESTION] ์ค‘ ํ•˜๋‚˜๋ฅผ ๋ฌธ์ œ์— ์ ‘๋‘์–ด๋กœ ๋ถ™์ด์‹ญ์‹œ์˜ค.

ํŒจํ‚ค์ง€ ๋ฒ„์ „, Laravel ๋ฒ„์ „

์˜ˆ์ƒ๋˜๋Š” ํ–‰๋™

์‹ค์ œ ํ–‰๋™

์˜ˆ์™ธ ์Šคํƒ ์ถ”์ 

์—‘์…€ ํŒŒ์ผ ์Šคํฌ๋ฆฐ์ƒท

ํ–‰๋™์„ ์žฌํ˜„ํ•˜๋Š” ๋‹จ๊ณ„

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

@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();

๋ชจ๋“  3 ๋Œ“๊ธ€

@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();
์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰