如果你用spire.xls (https://www.e-iceblue.cn/Introduce/Free-Spire-XLS-NET.html), 可以用Chart.PrimaryValueAxis.MajorUnit属性来设置Y轴的单位,小单位也可以通过MinorUnit来设置,不知道epplus有没有对应的属性。
用spire创建line3d的代码如下:
using Spire.Xls;
using Spire.Xls.Charts;
namespace InsertLinChart
{
class Program
{
static void Main(string[] args)
{
//创建Workbook
Workbook wb = new Workbook();
//获取第一个工作表
Worksheet sheet = wb.Worksheets[0];
//添加数据
sheet.Range["A1"].Value = "Country";
sheet.Range["A1"].Style.Font.IsBold = true;
sheet.Range["A2"].Value = "Cuba";
sheet.Range["A3"].Value = "Mexico";
sheet.Range["A4"].Value = "France";
sheet.Range["A5"].Value = "German";
sheet.Range["B1"].Value = "Sales";
sheet.Range["B1"].Style.Font.IsBold = true;
sheet.Range["B2"].NumberValue = 6000;
sheet.Range["B3"].NumberValue = 8000;
sheet.Range["B4"].NumberValue = 9000;
sheet.Range["B5"].NumberValue = 8500;
//添加Line3D图表
Chart chart = sheet.Charts.Add();
chart.ChartType = ExcelChartType.Line3D;
//设置Y轴单位
chart.PrimaryValueAxis.MajorUnit = 2000.00;
//设置数据区域
chart.DataRange = sheet.Range["A1:B5"];
chart.SeriesDataFromRange = false;
//设置图表位置
chart.LeftColumn = 1;
chart.TopRow = 5;
chart.RightColumn = 9;
chart.BottomRow = 25;
//设置标题
chart.ChartTitle = "Market share by country";
chart.ChartTitleArea.IsBold = true;
chart.ChartTitleArea.Size = 12;
foreach (ChartSerie cs in chart.Series)
{
cs.DataPoints.DefaultDataPoint.DataLabels.HasPercentage = true;
}
chart.Legend.Position = LegendPositionType.Top;
//保存文档
wb.SaveToFile("LineChart.xlsx", ExcelVersion.Version2016);
}
}
}
您好。我指的单位是数据的单位,m,个,次,ml这种