示例#1
0
        public static void ExportNamedRanges()
        {
            OfceExcel.Workbook WB = MyApp.ExcelApp.ActiveWorkbook;

            foreach (OfceExcel.Name NamedRange in WB.Names)
            {
                try
                {
                    OfceExcel.Range CurRange = NamedRange.RefersToRange;
                    CurRange.CopyPicture(OfceExcel.XlPictureAppearance.xlScreen, OfceExcel.XlCopyPictureFormat.xlBitmap);
                    MyApp.Fullpathname = MyApp.ExcelApp.ActiveWorkbook.Path + "\\" + WB.Name + "_" + NamedRange.Name + ".png";
                    sysImg.Imaging.ImageFormat PngFormat = sysImg.Imaging.ImageFormat.Png;
                    bool result = MyApp.SaveImage(MyApp.Fullpathname, PngFormat);
                }
                catch { }
                finally { }
            }



            foreach (OfceExcel.Worksheet WS in WB.Worksheets)
            {
                foreach (OfceExcel.Name NamedRange in WS.Names)
                {
                }
            }
        }
示例#2
0
        // ribbon callback
        public void OnButtonPressed(Microsoft.Office.Core.IRibbonControl control)
        {
            //string ExcelWBName = MyApp.ExcelApp.ActiveWorkbook.Name;
            //Debug.WriteLine(ExcelWBName);
            MyApp.ExportNamedRanges();
            ButtonPressedEventArgs args = new ButtonPressedEventArgs {
                ControlId = control
            };

            OnButtonPressedEvent(args);
        }
示例#3
0
 public void OnAction(Microsoft.Office.Core.IRibbonControl control)
 {
     Debug.WriteLine(control.Id);
     MyApp.ExportNamedRanges();
 }
示例#4
0
 public static void SaveWithWB(string filename)
 {
     MyApp.Fullpathname = MyApp.ExcelApp.ActiveWorkbook.Path + "\\" + filename + ".png";
     sysImg.Imaging.ImageFormat PngFormat = sysImg.Imaging.ImageFormat.Png;
     bool result = MyApp.SaveImage(MyApp.Fullpathname, PngFormat);
 }