Created
October 16, 2015 06:18
-
-
Save onocom/75afb05f19d369ef422e to your computer and use it in GitHub Desktop.
[PHPExcel] スタイルを維持したまま値を記述
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function set_value_with_style($pCoordinate = 'A1', $pValue = null, $sheet = null) { | |
$save_cell = 'A1'; // よっぽどA1に値が入っていることはないと想定してA1にスタイルを退避させる | |
if($sheet == null) $sheet = $this->current_sheet; | |
// A1セルに一旦スタイルを保存してから値を設定する | |
$sheet->duplicateStyle( $sheet->getStyle( $pCoordinate ), $save_cell ); | |
$sheet->setCellValue($pCoordinate , $pValue); | |
// スタイルを元に戻す | |
$sheet->duplicateStyle( $sheet->getStyle( $save_cell), $pCoordinate ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment