Beispiel #1
0
            public void PasteIn(Microsoft.Office.Interop.Excel.Range cell)
            {
                cell.ColumnWidth = 17;
                cell.RowHeight   = 33;
                //barcode.Save(path);

                //string datas = BarcodeScanner.ScanOne(path);
                var LinkToFile       = false;
                var saveWithDocument = true;
                var Left             = cell.Left + 2;
                var Top    = cell.Top + 2;
                var Width  = 0;
                var Height = 0;

                Microsoft.Office.Interop.Excel.Shape myShape = Globals.ThisAddIn.Application.ActiveSheet.Shapes.AddPicture(
                    Path,
                    LinkToFile,
                    saveWithDocument,
                    Left,
                    Top,
                    Width,
                    Height);
                ////'--(2) 挿入した画像に対して元画像と同じ高さ・幅にする
                myShape.ScaleHeight(0.6F, Office.MsoTriState.msoTrue);
                myShape.ScaleWidth(0.6F, Office.MsoTriState.msoTrue);

                //File.Delete(path);
            }
 public string[][] GetRange(string startRange, string endRange)
 {
     try
     {
         Microsoft.Office.Interop.Excel.Range currentRangeCells = this.excelWorksheet.get_Range(startRange, endRange);
         System.Array dataArray   = (System.Array)currentRangeCells.Cells.Value2;
         string[][]   stringArray = this.ToStringArray(dataArray);
         return(stringArray);
     }
     catch (Exception e)
     {
         if (e.Message.Contains("Exception: Conversion to string array"))
         {
             throw (e);
         }
         else
         {
             throw (new Exception("Exception: Range Extraction"));
         }
     }
 }
 public string[][] GetRange(string startRange)
 {
     try
     {
         Microsoft.Office.Interop.Excel.Range currentRangeCells = this.excelWorksheet.get_Range(startRange, System.Reflection.Missing.Value);
         string     range       = currentRangeCells.Cells.Value2 as string;
         char[]     splitter    = { ':' };
         string[]   rangeArray  = range.Split(splitter, 2);
         string[][] stringArray = GetRange(rangeArray[0], rangeArray[1]);
         return(stringArray);
     }
     catch (Exception e)
     {
         if (e.Message.Contains("Exception:"))
         {
             throw (e);
         }
         else
         {
             throw (new Exception("Exception: Range Extraction"));
         }
     }
 }
Beispiel #4
0
 public void ImportPdeTable(Microsoft.Office.Interop.Excel.Range eRange, Document wDoc)
 {
     mainManager.MainService.PropertyService.ImportPdeTable(eRange, wDoc);
 }
Beispiel #5
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            EnsurePowerPointIsRunning(true, true);

            //Instantiate slide object
            Microsoft.Office.Interop.PowerPoint.Slide objSlide = null;

            //Access the first slide of presentation
            objSlide = objPres.Slides[1];

            //Select firs slide and set its layout
            objSlide.Select();
            objSlide.Layout = Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank;

            //Add a default chart in slide
            objSlide.Shapes.AddChart(Microsoft.Office.Core.XlChartType.xl3DColumn, 20F, 30F, 400F, 300F);

            //Access the added chart
            Microsoft.Office.Interop.PowerPoint.Chart ppChart = objSlide.Shapes[1].Chart;

            //Access the chart data
            Microsoft.Office.Interop.PowerPoint.ChartData chartData = ppChart.ChartData;

            //Create instance to Excel workbook to work with chart data
            Microsoft.Office.Interop.Excel.Workbook dataWorkbook = (Microsoft.Office.Interop.Excel.Workbook)chartData.Workbook;

            //Accessing the data worksheet for chart
            Microsoft.Office.Interop.Excel.Worksheet dataSheet = dataWorkbook.Worksheets[1];

            //Setting the range of chart
            Microsoft.Office.Interop.Excel.Range tRange = dataSheet.Cells.get_Range("A1", "B5");

            //Applying the set range on chart data table
            Microsoft.Office.Interop.Excel.ListObject tbl1 = dataSheet.ListObjects["Table1"];
            tbl1.Resize(tRange);

            //Setting values for categories and respective series data

            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A2"))).FormulaR1C1 = "Bikes";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A3"))).FormulaR1C1 = "Accessories";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A4"))).FormulaR1C1 = "Repairs";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("A5"))).FormulaR1C1 = "Clothing";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B2"))).FormulaR1C1 = "1000";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B3"))).FormulaR1C1 = "2500";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B4"))).FormulaR1C1 = "4000";
            ((Microsoft.Office.Interop.Excel.Range)(dataSheet.Cells.get_Range("B5"))).FormulaR1C1 = "3000";

            //Setting chart title
            ppChart.ChartTitle.Font.Italic               = true;
            ppChart.ChartTitle.Text                      = "2007 Sales";
            ppChart.ChartTitle.Font.Size                 = 18;
            ppChart.ChartTitle.Font.Color                = Color.Black.ToArgb();
            ppChart.ChartTitle.Format.Line.Visible       = Microsoft.Office.Core.MsoTriState.msoTrue;
            ppChart.ChartTitle.Format.Line.ForeColor.RGB = Color.Black.ToArgb();

            //Accessing Chart value axis
            Microsoft.Office.Interop.PowerPoint.Axis valaxis = ppChart.Axes(Microsoft.Office.Interop.PowerPoint.XlAxisType.xlValue, Microsoft.Office.Interop.PowerPoint.XlAxisGroup.xlPrimary);

            //Setting values axis units
            valaxis.MajorUnit    = 2000.0F;
            valaxis.MinorUnit    = 1000.0F;
            valaxis.MinimumScale = 0.0F;
            valaxis.MaximumScale = 4000.0F;

            //Accessing Chart Depth axis
            Microsoft.Office.Interop.PowerPoint.Axis Depthaxis = ppChart.Axes(Microsoft.Office.Interop.PowerPoint.XlAxisType.xlSeriesAxis, Microsoft.Office.Interop.PowerPoint.XlAxisGroup.xlPrimary);
            Depthaxis.Delete();

            //Setting chart rotation
            ppChart.Rotation       = 20; //Y-Value
            ppChart.Elevation      = 15; //X-Value
            ppChart.RightAngleAxes = false;

            // Save the presentation as a PPTX
            objPres.SaveAs("VSTOSampleChart", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);

            //Close Workbook and presentation
            dataWorkbook.Application.Quit();
            objPres.Application.Quit();
        }