我现在遇到了,chart图表显示中文出现乱码的问题
现象如“麻烦请教下,导出Excel带chart图表中中文部分是乱码”帖子中所显示的样子
我使用DOF推荐的第二种方法
“2、使用下面的方式添加图表fpSpread1.ActiveSheet.AddChart(new FarPoint.Win.Spread.Model.CellRange(0, 0, 4, 5), typeof(FarPoint.Win.Chart.BarSeries), 500, 300, 0, 100);”
来做的但是我这显示效果没有发生变化
我图表生成代码如下
- //初始化
- fpSpread_Bar.Sheets[0].Charts.Clear();
- fpSpread_Bar.Sheets[0].RowCount = 1;
- BarSeries bseries_People = new BarSeries();
- bseries_People.GapWidth = 0.25F;
- bseries_People.BarFill = new SolidFill(Color.IndianRed);
- bseries_People.SeriesName = "预约人数";
- bseries_People.LabelVisible = true;
- //获得图标数据源
- int iCount = 0;
- for (int i = 0; i < fpSpread_Table.Sheets[0].RowCount - 2; i++)
- {
- if (fpSpread_Table.Sheets[0].Cells[i, 1].Text != "")
- {
- bseries_People.Values.Add(Convert.ToDouble(fpSpread_Table.Sheets[0].Cells[i, 1].Text));
- bseries_Cost.Values.Add(Convert.ToDouble(fpSpread_Table.Sheets[0].Cells[i, 2].Text));
- if (fpSpread_Table.Sheets[0].Cells[i, 0].Text != "")
- {
- bseries_People.CategoryNames.Add(fpSpread_Table.Sheets[0].Cells[i, 0].Text);
- bseries_Cost.CategoryNames.Add(fpSpread_Table.Sheets[0].Cells[i, 0].Text);
- }
- iCount++;
- }
- }
- if (iCount <= 0) return; //当收集数据源为空时,退出
- fpSpread_Bar.Sheets[0].AddColumns(0, iCount*2);
- fpSpread_Bar.Sheets[0].AddRows(0, 38); //添加相应高度的行数,否则滚动条异常
- //设置柱形样式
- YPlotArea plotArea_People = new YPlotArea();
- plotArea_People.Location = new PointF(0.1f, 0.2f);
- plotArea_People.Size = new SizeF(0.8f, 0.6f);
- plotArea_People.Series.Add(bseries_People);
- //添加标题
- LabelArea label_People = new LabelArea();
- label_People.Location = new PointF(0.5f, 0.02f);
- label_People.AlignmentX = 0.5f;
- label_People.AlignmentY = 0.0f;
- label_People.Text = "柱形图-预约人数";
- //组合图表
- ChartModel model_People = new ChartModel();
- model_People.PlotAreas.Add(plotArea_People);
- model_People.LabelAreas.Add(label_People);
- //插入到表格中
- fpSpread_Bar.ActiveSheet.AddChart(new FarPoint.Win.Spread.Model.CellRange(0, 0, 14, 15), typeof(BarSeries), fpSpread_Bar.Width - 30, 385, 0, 0);
- fpSpread_Bar.ActiveSheet.Charts[0].Model = model_People;
- fpSpread_Bar.ActiveSheet.Charts[0].Locked = true;
复制代码
我写法有什么问题吗?我下方的说明文字不可能去除,有没有方法来解决这个问题?我试验了下,在设计器中不存在该问题
谢谢你的帮助 |
|