目前使用EPPlus v4.1.1产生的Excel报表
使用OpenOffice看不到Chart
用LibreOffice比较好点
有看到框和点,但背景是空且颜色也不对
用MS Office就能正常开启
再用MS Office另存新档上述两套就能正常显示
请问有好的解法吗?
感谢
测试程式码如下
using (ExcelPackage p = new ExcelPackage())
{
ExcelWorksheet ws = p.Workbook.Worksheets.Add("Report");
//header
ws.Cells[1, 1].Value = "No";
ws.Cells[1, 2].Value = "Data";
//data
Random rnd = new Random((int)DateTime.Now.Ticks);
for (int i = 0; i < 20; i++)
{
ws.Cells[i + 2, 1].Value = i;
ws.Cells[i + 2, 2].Value = rnd.Next(0, 10);
}
//chart
var ttvMidChart = ws.Drawings.AddChart("Data", eChartType.XYScatterLines)
as ExcelScatterChart;
ttvMidChart.SetPosition(2, 0, 3, 0);
ttvMidChart.SetSize(64 * 10, 21 * 10);
var serie1 = ttvMidChart.Series.Add(ExcelRange.GetAddress(2, 2, 2 + 20 -
1, 2), ExcelRange.GetAddress(2, 1, 2 + 20 - 1, 1));
serie1.Header = ws.Cells[1, 2].Value.ToString();
p.SaveAs(new FileInfo("excel_text.xlsx"));
}