Microsoft.Office.Interop.Word.Table myWordable; Microsoft.Office.Interop.Word.Range myWordRange; FileStream myfile = Path.Combine(filepath, "Test_Excel.xlsx"); using (ExcelPackage package = new ExcelPackage(myfile)) { ExcelWorksheet myws = package.Workbook.Worksheets[1]; myWordTable = new_mach.myWordApplication.ActiveDocument.Tables[5]; myWordRange = new_mach.myWordTable.Cell(2, 1).Range; Microsoft.Office.Interop.Word.InlineShape objshape = new_mach.myWordDoc.InlineShapes.AddChart(Microsoft.Office.Core.XlChartType.xlXYScatterSmoothNoMarkers, new_mach.myWordRange); Microsoft.Office.Interop.Word.Chart mychrt = objshape.Chart; Workbook wb = mychrt.ChartData.Workbook; Worksheet datasheet = wb.Worksheets["Sheet1"]; Microsoft.Office.Interop.Excel.Range myrng = datasheet.get_Range("A1","D10"); Microsoft.Office.Interop.Excel.ListObject tbl = datasheet.ListObjects["Table1"]; tbl.Resize(myrng); mychrt.HasLegend = true; mychrt.Legend.Position = Microsoft.Office.Interop.Word.XlLegendPosition.xlLegendPositionBottom; mychrt.Legend.Format.Line.Style = Microsoft.Office.Core.MsoLineStyle.msoLineSingle; mychrt.Legend.Format.Line.Visible = Microsoft.Office.Core.MsoTriState.msoCTrue; Microsoft.Office.Interop.Word.Series sr = mychrt.SeriesCollection(1); sr.Border.Color = Color.Red; sr.Name = "Charging"; sr = mychrt.SeriesCollection(2); sr.Name = "Discharging"; sr.Border.Color = Color.Navy; Microsoft.Office.Interop.Word.Axis vertaxis = (Microsoft.Office.Interop.Word.Axis)mychrt.Axes(Microsoft.Office.Interop.Word.XlAxisType.xlValue, Microsoft.Office.Interop.Word.XlAxisGroup.xlPrimary); vertaxis.HasMajorGridlines = true; vertaxis.HasTitle = true; vertaxis.AxisTitle.Text = "Pol-Depol Currents (microAmp)"; vertaxis.HasMinorGridlines = true; vertaxis.LogBase = 10; Microsoft.Office.Interop.Word.Axis Horiaxis = (Microsoft.Office.Interop.Word.Axis)mychrt.Axes(Microsoft.Office.Interop.Word.XlAxisType.xlCategory, Microsoft.Office.Interop.Word.XlAxisGroup.xlPrimary); Horiaxis.HasMajorGridlines = true; Horiaxis.HasTitle = true; Horiaxis.AxisTitle.Text = "time (sec)"; Horiaxis.HasMinorGridlines = true; Horiaxis.LogBase = 10; Horiaxis.MinimumScale = 1; Horiaxis.MaximumScale = 1000; Horiaxis.TickLabelPosition = Microsoft.Office.Interop.Word.XlTickLabelPosition.xlTickLabelPositionLow; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)