[問題] EPPlus產生圖表OpenOffice看不到

作者: ghostx2 (Ghostx2)   2017-10-18 20:04:21
目前使用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"));
}

Links booklink

Contact Us: admin [ a t ] ucptt.com