抖音资讯

douyinzx

word插件开发支持哪些语言(word开发工具属性)

iseeyu2年前 (2024-05-08)抖音资讯106

1, 在excel里面多个柱状图会重叠在图表里面,这是因为多个柱状图不重叠的话type要设置成Orig.ChartType =
XlChartType.xlColumnClustered;; 重叠的话,Orig.ChartType = XlChartType.xlColumnStacked;

2 关于图例:如果设置position 的话,图例会横向排列,不设置

// chart.Legend.Position =
Excel.XlLegendPosition.xlLegendPositionTop; 图例会竖着排列

chart.Legend.Left = 80;

chart.Legend.Height = 15* list.Count();

chart.Legend.IncludeInLayout = true;

chart.Legend.Top = 0;

chart.Legend.Width = 150;

// chart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionTop;

chart.Legend.Font.Color = ColorTranslator.ToOle(Color.Black);

3 xAxis.MinorTickMark =
Excel.XlTickMark.xlTickMarkOutside;坐标轴刻度


xAxis.TickLabels.NumberFormat = "yyyy-mm-dd"; 坐标轴时间设置

4 调用
Microsoft.Office.Interop.Excel.Shape myChart = newWorksheet.Shapes.AddChart2(-1, XlChartType.xlLine, 250, 50, width, 165, true); 会在图表默认生成一条空数据的图形,要删除

Excel.SeriesCollection seriescollectionB2 = chart.SeriesCollection();

int cc = seriescollectionB2.Count;

seriescollectionB2.Item(1).Delete();

 

#function

public static Microsoft.Office.Interop.Excel.Shape GetChart(Excel.Application eApp,Document document, WordCharItem onechartData, ContentControl c, int width)

{

Excel.Worksheet newWorksheet = eApp.Worksheets.Add();//获取第一个Worksheet

//newWorksheet.Activate();

//向表格中插入数据

string[,] array = ExtractHelper.GetKeppArray(onechartData.chartIndexDataList);

var list = onechartData.chartIndexList.OrderBy(p => p.axisType);

int indexcount = list.Count();

int rowIndex = 0;

int columnIndex = 1;

int columnlength1 = onechartData.chartIndexDataList[0].Split(ExtractHelper.splitchar).Length;

int headerCount = 1;

int lenght = onechartData.chartIndexDataList.Length - headerCount;

int rowlenght = onechartData.chartIndexDataList.Length - 1;

Microsoft.Office.Interop.Excel.Range c1 = newWorksheet.Cells[rowIndex + 1, columnIndex];

Microsoft.Office.Interop.Excel.Range c3 = newWorksheet.Cells[rowIndex + rowlenght, columnlength1];

Microsoft.Office.Interop.Excel.Range range3 = newWorksheet.Range[c1, c3];

range3.Value2 = array;

//range3.NumberFormat= numberFormat;

int SeriesCount = onechartData.chartIndexList.Count();

Microsoft.Office.Interop.Excel.Range timeStartRange = newWorksheet.Cells[1, 1];

Microsoft.Office.Interop.Excel.Range timeEndRange = newWorksheet.Cells[rowlenght, 1]; ;

Microsoft.Office.Interop.Excel.Range XValues = newWorksheet.Range[timeStartRange, timeEndRange];

XValues.NumberFormat = "yyyy/m/d";

Microsoft.Office.Interop.Excel.Range dataStartRange = newWorksheet.Cells[1, 2];

Microsoft.Office.Interop.Excel.Range dataEndRange = newWorksheet.Cells[rowlenght, columnlength1];

Microsoft.Office.Interop.Excel.Range dataRANGE = newWorksheet.Range[dataStartRange, dataEndRange];

dataRANGE.NumberFormat = numberFormat;

Microsoft.Office.Interop.Excel.Shape myChart = newWorksheet.Shapes.AddChart2(-1, XlChartType.xlLine, 250, 50, width, 165, true);

Excel.Chart chart = myChart.Chart;

// 设置图表标题

chart.HasTitle = true;

chart.ChartTitle.Text = onechartData.title;

chart.ChartTitle.Font.Name = zhongwenstr;

chart.ChartTitle.Font.Size = 8f;

chart.ChartTitle.Font.Bold = 1;

chart.ChartTitle.Font.Color = ColorTranslator.ToOle(Color.Black);

chart.ChartTitle.HorizontalAlignment = XlConstants.xlLeft;

chart.ChartTitle.Left = 0;

//chart.ChartArea.Left = 0;

chart.PlotArea.InsideLeft = 3;

chart.PlotArea.InsideWidth = 230;

Excel.SeriesCollection seriescollectionB2 = chart.SeriesCollection();

seriescollectionB2.Item(1).Delete();

string[] xarray = RangeHelper.GetOneColumnRange(XValues);

for (int i = 1; i <= indexcount; i++)

{

Excel.Series Orig = seriescollectionB2.NewSeries();

double[] yarrayy = new double[rowlenght];

for (int ii = 1; ii <= rowlenght; ii++)

{

Microsoft.Office.Interop.Excel.Range range = newWorksheet.Cells[ii, i + 1];

if (string.IsNullOrEmpty(range.Value2))

{

// yarrayy[ii - 1] = 0;

}

else

{

yarrayy[ii - 1] = Convert.ToDouble(range.Value2);

}

}

Orig.Name = list.ElementAt(i - 1).indexName;

Orig.XValues = xarray;

word插件开发支持哪些语言(word开发工具属性)

Orig.Values = yarrayy;

Orig.HasDataLabels = false;

if (i == 1)

{

Orig.AxisGroup = Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary;

if (list.ElementAt(i-1).type == 1)

{

Orig.ChartType = XlChartType.xlLineStacked;

Orig.Format.Line.Weight = 1.2f;

Orig.Format.Line.ForeColor.RGB = StyleHelper.GetColorIntRGB(linecolor);

}

if (list.ElementAt(i-1).type == 2)

{

Orig.ChartType = XlChartType.xlColumnStacked;

Orig.Interior.Color = ColorTranslator.ToOle(Color.Gray);

}

Excel.Axis yAxis = (Excel.Axis)chart.Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary);

yAxis.HasDisplayUnitLabel = true;

yAxis.DisplayUnitCustom = 1;

yAxis.DisplayUnitLabel.Orientation = XlOrientation.xlHorizontal;

yAxis.DisplayUnitLabel.Left = 15;

yAxis.DisplayUnitLabel.Top = 10;

yAxis.DisplayUnitLabel.Font.Name = zhongwenstr;

yAxis.DisplayUnitLabel.Font.Size = 8f;

//yAxis.DisplayUnit=XlDisplayUnit.

yAxis.TickLabels.Font.Name = fontname;

yAxis.TickLabels.Font.Size = fontsize;

yAxis.TickLabels.Font.Color = XlRgbColor.rgbBlack;

yAxis.MajorTickMark = Excel.XlTickMark.xlTickMarkOutside;

yAxis.HasMinorGridlines = false;

yAxis.HasMajorGridlines = false;

yAxis.Format.Line.ForeColor.RGB = (int)XlRgbColor.rgbBlack;

yAxis.Format.Line.Weight = 1;

yAxis.Border.Color = ColorTranslator.ToOle(Color.Black);//y轴颜色

yAxis.DisplayUnitLabel.Text = list.ElementAt(i-1).unit;

 

}

if (i == 2)

{

if (list.ElementAt(i-1).type == 1)

{

Orig.ChartType = XlChartType.xlLineStacked;

Orig.Format.Line.Weight = 1.2f;

Orig.Format.Line.ForeColor.RGB = StyleHelper.GetColorIntRGB("0,174,239");

}

if (list.ElementAt(i-1).type == 2)

{

Orig.ChartType = XlChartType.xlColumnStacked;

Orig.Interior.Color = ColorTranslator.ToOle(Color.Gray);

}

 

Orig.AxisGroup = Microsoft.Office.Interop.Excel.XlAxisGroup.xlSecondary;

Excel.Axis ysecondAxis = (Excel.Axis)chart.Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlSecondary);

ysecondAxis.HasDisplayUnitLabel = true;

//ysecondAxis.DisplayUnit = XlDisplayUnit.xlHundreds;

ysecondAxis.DisplayUnitCustom = 1;

ysecondAxis.DisplayUnitLabel.Left = 210;

ysecondAxis.DisplayUnitLabel.Top = 10;

//ysecondAxis.DisplayUnitLabel.VerticalAlignment=

ysecondAxis.DisplayUnitLabel.Orientation = XlOrientation.xlHorizontal;

ysecondAxis.DisplayUnitLabel.Position = Excel.XlChartElementPosition.xlChartElementPositionCustom;

ysecondAxis.DisplayUnitLabel.Font.Name = zhongwenstr;

ysecondAxis.DisplayUnitLabel.Font.Size = 8f;

ysecondAxis.TickLabels.Font.Name = fontname;

ysecondAxis.TickLabels.Font.Size = fontsize;

ysecondAxis.TickLabels.Font.Color = ColorTranslator.ToOle(Color.Black);

ysecondAxis.DisplayUnitLabel.Text = list.ElementAt(i-1).unit;

ysecondAxis.Border.Color = ColorTranslator.ToOle(Color.Black);//y轴颜色

}

if (i == 3)

{

Orig.AxisGroup = Microsoft.Office.Interop.Excel.XlAxisGroup.xlSecondary;

if (list.ElementAt(i-1).type == 1)

{

Orig.ChartType = XlChartType.xlLine;

Orig.Format.Line.ForeColor.RGB = StyleHelper.GetColorIntRGB(linecolor);

Orig.Format.Line.Weight = 1.2f;

}

if (list.ElementAt(i-1).type == 2)

{

Orig.ChartType = XlChartType.xlColumnClustered;

Orig.Interior.Color = ColorTranslator.ToOle(Color.Gray);

}

Orig.HasDataLabels = false;

//StyleHelper.SetSeries(Orig, "55,155,30");

Orig.Format.Line.ForeColor.RGB = StyleHelper.GetColorIntRGB(linecolor);

Orig.Format.Line.Weight = 1;

Excel.Axis ysecondAxis = (Excel.Axis)chart.Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlSecondary);

ysecondAxis.HasDisplayUnitLabel = true;

ysecondAxis.DisplayUnitCustom = 1;

ysecondAxis.DisplayUnitLabel.Orientation = XlOrientation.xlHorizontal;

ysecondAxis.DisplayUnitLabel.Font.Name = zhongwenstr;

ysecondAxis.DisplayUnitLabel.Font.Size = 8f;

ysecondAxis.TickLabels.Font.Name = fontname;

ysecondAxis.TickLabels.Font.Size = fontsize;

ysecondAxis.TickLabels.Font.Color = XlRgbColor.rgbBlack;

ysecondAxis.DisplayUnitLabel.Text = list.ElementAt(i-1).unit;

ysecondAxis.Border.Color = ColorTranslator.ToOle(Color.Black);//y轴颜色

}

if (i == 4)

{

Orig.AxisGroup = Microsoft.Office.Interop.Excel.XlAxisGroup.xlSecondary;

if (list.ElementAt(i-1).type == 1)

{

Orig.ChartType = XlChartType.xlXYScatterLinesNoMarkers;

Orig.Format.Line.ForeColor.RGB = StyleHelper.GetColorIntRGB("0,174,239");

Orig.Format.Line.Weight = 1.2f;

}

if (list.ElementAt(i-1).type == 2)

{

Orig.Interior.Color = StyleHelper.GetColorIntRGB("0,55,120");

Orig.ChartType = XlChartType.xlColumnClustered;

}

//StyleHelper.SetSeries(Orig, "5,15,130");

Orig.Format.Line.ForeColor.RGB = StyleHelper.GetColorIntRGB(linecolor);

Orig.Format.Line.Weight = 1;

Excel.Axis ysecondAxis = (Excel.Axis)chart.Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlSecondary);

ysecondAxis.HasDisplayUnitLabel = true;

ysecondAxis.DisplayUnitLabel.Orientation = XlOrientation.xlHorizontal;

ysecondAxis.DisplayUnitCustom = 1;

ysecondAxis.DisplayUnitLabel.Font.Name = zhongwenstr;

ysecondAxis.DisplayUnitLabel.Font.Size = 8f;

ysecondAxis.TickLabels.Font.Name = fontname;

ysecondAxis.TickLabels.Font.Size = fontsize;

ysecondAxis.TickLabels.Font.Color = XlRgbColor.rgbBlack;

ysecondAxis.DisplayUnitLabel.Text = list.ElementAt(i-1).unit;

ysecondAxis.Border.Color = ColorTranslator.ToOle(Color.Black);//y轴颜色

}

}

// 设置y轴

//设置Y轴的显示

 

//yAxis.HasTitle = true;

Excel.Axis xAxis = (Excel.Axis)chart.Axes(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary);

 

xAxis.CategoryNames = xarray;

//xAxis.CategoryType = Excel.XlCategoryType.xlTimeScale;

xAxis.TickLabelPosition = Excel.XlTickLabelPosition.xlTickLabelPositionLow;

xAxis.TickLabels.Orientation = Excel.XlTickLabelOrientation.xlTickLabelOrientationDownward;

xAxis.TickLabels.Font.Name = fontname;

xAxis.TickLabels.NumberFormat = "yyyy-mm-dd";

xAxis.TickLabels.Font.Size = 8f;

xAxis.TickLabels.Font.Color = XlRgbColor.rgbBlack;

xAxis.MinorTickMark = Excel.XlTickMark.xlTickMarkOutside;

// xAxis.HasTitle = true;

//xAxis.AxisTitle.Orientation = Excel.XlOrientation.xlHorizontal;

 

//yAxis.HasDisplayUnitLabel = true;

xAxis.Format.Line.ForeColor.RGB = (int)XlRgbColor.rgbBlack;

xAxis.Format.Line.Weight = 1;

xAxis.Border.Color = ColorTranslator.ToOle(Color.Black);//y轴颜色

xAxis.TickLabels.MultiLevel = true;

chart.HasLegend = true;

chart.ChartTitle.Font.Name = zhongwenstr;

chart.Legend.Left = 80;

chart.Legend.Height = 15 * indexcount;

chart.Legend.IncludeInLayout = true;

chart.Legend.Top = 0;

chart.Legend.Width = 150;

// chart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionTop;

chart.Legend.Font.Color = ColorTranslator.ToOle(Color.Black);

chart.Legend.Font.Name = zhongwenstr;

chart.Legend.Font.Size = 8f;

return myChart;

扫描二维码推送至手机访问。

版权声明:本文由西安泽虎代运营发布,如需转载请注明出处。

转载请注明出处https://0291.com.cn/post/42444.html

相关文章

优/低质标准及案例解析 | 快手推广平台

优/低质标准及案例解析 | 快手推广平台

一、快手广告推广优质标准解读  重点纬度 重点优质点拆解 素材类型  1、真人出镜实拍类素材较纯剪辑素材更易被判为优质; 2、剪辑类素材若源剪辑视频质量较高,则也可被判为优质; 3、无特定设...

抖音多少级可以飘屏打字(抖音视频飘字的设置)

抖音多少级可以飘屏打字(抖音视频飘字的设置)

现在很多人都喜欢看直播,在观看抖音直播时会发现有些直播间非常受欢迎,而且观看体验很好,直播间的场景搭建、装饰、背景墙、服饰搭配、商品链接等因素,都会影响直播间的观看感。在观看带货直播间发现很多直播的屏幕上有字幕,有些是下场直播预告的信息,有些是本场直播的优惠力度信息,也有些是用户评论,这些...

快手推广渠道有哪些?快手代理哪家好?

快手推广渠道有哪些?快手代理哪家好?

摘要: 快手主要推广渠道有3种:1蹭热度、2大号带小号、3利用社群分裂粉丝,这些方法是在快手推广最常运用到的,但是实际操作起来也并不简单,所以很多广告主在进行快手推广时会选择快手代理来解决。 最近几年最火的app是哪个?毫无疑问很多人的答案都是快手,说快手已经掀起全民热潮真的毫不夸张,不信你可以...

上传视频能赚钱的平台有哪些?上传视频能赚钱

上传视频能赚钱的平台有哪些?上传视频能赚钱

上传视频能赚钱的平台有哪些?上传视频能赚钱的平台介绍 哪些平台上传视频可以赚钱? 1.企鹅,腾讯短视频平台 很多朋友从来没有听说过企鹅。其实是腾讯的自媒体平台,也是很多朋友选择的平台之一。但是这个平台入驻要求有点高,赚钱也没那么容易,不适合初学者。但是如果你的视...

canvas动画的实现原理(canvas包含内置动画)

canvas动画的实现原理(canvas包含内置动画)

主要用到的函数也就是arc函数 实现的核心其实是增量,就是上次结束的弧度成为下次弧度的开始,便可以平滑过度。 关于动画,有个实现原理,就是一秒最少要20fps。(fps是帧) 效果图     一言不合贴的代码:...

excel生成指定范围的随机数(随机生成一个时间段的时间)

excel生成指定范围的随机数(随机生成一个时间段的时间)

今天跟大家分享一下如何利用Excel生成和为指定数的随机数   1.如下图我们想要生成和为100的12个随机数。   2.选中D2:F5单元格区域   3.点...

现在,非常期待与您的又一次邂逅

我们努力让每一部企业宣传片和抖音短视频成为商业大片