- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经完成了我的工作,直到在 excel 中获取 SQL 表数据,但我还想使用 PHPEXCEL 将数据转换为条形图。有人知道吗?怎么做?我的 PHPEXCEL 代码如下,
$sql = "SELECT sum(Ticket) AS count, Applications FROM Temp_table GROUP BY Apps";
$result = $conn->query($sql);
if($result->num_rows > 0)
{
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$rownumber = 2;
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Applications');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Count');
while($row = $result->fetch_assoc())
{
$objPHPExcel->getActiveSheet()->setCellValue('A'.$rownumber, $row["Applications"]);
$objPHPExcel->getActiveSheet()->setCellValue('B'.$rownumber, $row["count"]);
$rownumber++;
}
$objPHPExcel->getActiveSheet()->setTitle('Sheet1');
}
最佳答案
这是条形图的代码
// Set the Labels for each data series we want to plot
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Data!$D$1', NULL, 1), // 2011
);
// Set the X-Axis Labels
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$xAxisTickValues = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Data!$A$2:$A$5', NULL, 6), // Q1 to Q4
);
// Set the Data values for each data series we want to plot
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$dataSeriesValues = array(
new PHPExcel_Chart_DataSeriesValues('Number', 'Data!$D$2:$D$5', NULL, 6),
);
// Build the dataseries
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
// Set additional dataseries parameters
// Set the series in the plot area
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
$title = new PHPExcel_Chart_Title('Topic Relevance');
$yAxisLabel = new PHPExcel_Chart_Title('Points');
// Create the chart
$chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel
$yAxisLabel // yAxisLabel
);
// Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('B10');
$chart->setBottomRightPosition('F25');
// Add the chart to the worksheet
$objWorksheet->addChart($chart);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//this line is necessary to display chart in excel
$objWriter->setIncludeCharts(TRUE);
关于PHPExcel 条形图使用 PHPExcel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41619302/
我已经完成了我的工作,直到在 excel 中获取 SQL 表数据,但我还想使用 PHPEXCEL 将数据转换为条形图。有人知道吗?怎么做?我的 PHPEXCEL 代码如下, $sql = "SELEC
我想阅读 Excel 工作表下拉列表中给出的选项列表。 例如: - 有一个单元格(86,G)没有尝试作为选项,但它是一个下拉列表。所以无论用户选择什么,我都想从下拉列表中读取最后一个选项。 如何实现这
我在使用 PHPExcel 设置自定义日期格式时遇到了一个奇怪的问题:我正在将一个 sql 格式的日期写入一个单元格,并使用 setFormatCode 将其格式设置为“d/m/y”。当我在 Exce
在 PHPExcel 中创建 XLS 文档时如何为事件单元格设置特定颜色? 最佳答案 $sheet->getStyle('A1')->applyFromArray( array(
我需要生成Excel文件,我进行了搜索,phpexcel似乎很好而且稳定。我想知道:* 鉴于它是一个 symfony2.0 项目,如何将它集成到我的项目中* 如果我可以通过这个 php 库完成我通常在
我在使用 PHPExcel 时遇到以下问题 function Test($a, $b) { // Create a new PHPExcel object with a single she
我想使用 PHPExcel 从 Excel 工作表中删除所有以“//”开头的行。我的代码: require '../Classes/PHPExcel.php'; require_once '../Cl
我的 EXCEL 到 CSV 转换代码正在运行...但对于特定的 Excel 文件,它出现错误 在第 950 行/var/www/portal/user/admin/pe/Classes/PHPExc
我正在使用 PHPExcel 库,我无法更改图表的颜色。 谁有解决办法,请告诉我? 检查这个屏幕我想改变蓝色、红色和绿色的颜色: 最佳答案 当前版本的 PHPExcel 不支持这样做。 在 this
我正在尝试将 PHPExcel 包含到 Silverstripe 3 站点以导出 Excel 工作表。现在我只是想测试,但在尝试时出现此错误: [Warning] require_once(/site
当我尝试从 excel 文件中提取信息时遇到了这个问题。这是我的情况,我从不同用户那里收到了 34 个 Excel 文件。 我正在使用 PHP 版本 5 从 Excel 文件中提取。我的脚本将循环每个
我有来自 phpExel 的这段代码。 $objPHPExcel->setActiveSheetIndex(1)->mergeCells('A1:I1'); 此代码在 A1 到 I1 列之间创建了一些
我正在使用 phpexcel 将我的查询导出到 excel 文件中;但是在我创建文件(xslx 格式)后,我无法在 excel 中打开我的文件。它给出了“文件格式或扩展名无效。验证文件没有损坏并且文件
我有以下代码: $vOffset = 2; $offset = 6; $formatRows = 100; $formatColumns = 100; //set conditional format
我正在尝试生成包含多个工作表的 Excel 文件,并且该文件正在使用正确的数据生成,但在打开它时出错。 错误是: 此外,当我尝试通过循环遍历工作表时,我无法访问除第一页外的工作表。 发生 PHP 错误
我在将 .xlsx 文件转换为 .csv 时遇到问题。当我尝试转换它时,会出现 csv 文件并激活 Text Wrap。问题是,我需要将该 csv 文件导入数据库,而当前格式不允许我这样做。我有一个问
这是我的电子表格中的内容: 12/04/2011 8:56:17 p.m. (xls dateserial = 40645.87242) 这是我用来提取日期并在 PHP 中转换为日期字符串的代码:
我正在使用 setReadDataOnly(true) 读取 XLS 文件。读取的对象将再次保存为新的 Excel 文件。不幸的是,某些单元格值计算不正确(这与使用小计公式的单元格的计算错误有关)。如
有谁知道用于将图案样式添加到单元格颜色的语法?我想添加一条细的反向斜条纹。 最佳答案 据我所知,这是不可能的。在 \Style\Fill.php ,这些似乎是唯一的选择,尽管可能会有更多选择的更新版本
我对拥有一些文件的PHPExcel的行为感到有些困惑。 这些文件包含大约。 3000行数据,但是根据PHPExcel,最后使用的行是65535。我尝试从文件中剪切几行并将其粘贴到新文件中,但无济于事。
我是一名优秀的程序员,十分优秀!