1
A
回答
0
$outputFileType = 'Excel2007';
$outputFileName = 'testWrite.xlsx';
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/');
/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';
// Instantiate a new PHPExcel object and set some data
$objPHPExcel = new PHPExcel();
$cellData = magicSquare(4);
$objPHPExcel->getActiveSheet()->fromArray($cellData);
// Define a style to set
$styleArray = array('font' => array('bold' => true,
)
);
// And a range of cells to set it for
$fromCol = 'A';
$toCol = 'C';
$fromRow = 1;
$toRow = 3;
$cellRange = $fromCol . $fromRow . ':' . $toCol . $toRow;
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($styleArray);
// Save the workbook
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $outputFileType);
$objWriter->save($outputFileName);
function magicSquare($size) {
$row = 1;
$column = ceil($size/2);
$result = array();
$valueCount = $size*$size;
for ($i = 1; $i <= $valueCount; $i++) {
$result[$row][$column] = $i;
if (($i % $size) == 0) {
$row++;
} else {
$row--;
$column++;
}
if ($row <= 0) {
$row = $size;
} elseif($row > $size) {
$row = 1;
}
if ($column <= 0) {
$column = $size;
} elseif ($column > $size) {
$column = 1;
}
}
ksort($result);
foreach($result as &$row) {
ksort($row);
}
return $result;
}
相關問題
- 1. 粗體動態選擇文本
- 2. RichTextBlock對指定文本範圍的粗體效果
- 3. textarea中的粗體文本
- 4. GroupBox中的粗體文本
- 5. 動態文本中的粗體和常規字體在面具下動態文本在AS3的Flash中
- 6. 格式化動態範圍爲文本
- 7. 試圖將動態NSString文本轉換爲粗體文本
- 8. IP範圍從和IP範圍到 - 動態文本框
- 9. 將動態範圍文本複製到另一個範圍
- 10. 文本區域中的粗體文本?
- 11. 動態範圍
- 12. Excel中的動態範圍
- 13. 動態範圍內的VBA範圍值
- 14. 如何將文本動態改爲粗體?
- 15. 動態文本丟失了粗體樣式
- 16. VBA:Protection.AllowEditRanges動態範圍
- 17. 爲什麼粗體顯示爲粗體的文本呈現爲「超級粗體」?
- 18. 字符串中的粗體文本
- 19. Windows 8 Live Tile中的粗體文本
- 20. RichTextBox中的部分文本爲粗體
- 21. HTML中的粗體西里爾文本
- 22. 在php輸出中的粗體文本
- 23. Qbasic中的粗體輸出文本
- 24. gnuplot中的粗體增強文本
- 25. Blackberry:LabelField文本的粗體字體
- 26. 粗體和正常文本
- 27. 選擇粗體文本
- 28. 製作TabLayout文本粗體
- 29. 粗體搜索文本
- 30. TabHost Android使文本粗體
你需要跟蹤你正在使用某種方式的單元格區域的 –