Пример #1
0
 //ЗАПИСЬ КАРТИНКИ В ЯЧЕЙКУ
 public void AddPicture(string path, string cellAdress)
 {
     SelectCells(cellAdress, cellAdress);
     _p        = _xlWorkSheet.Pictures(_misValue) as Excel.Pictures;
     _pic      = _p.Insert(path, _misValue);
     _pic.Left = Convert.ToDouble(_range.Left);
     _pic.Top  = Convert.ToDouble(_range.Top);
 }
Пример #2
0
 //ЗАПИСЬ КАРТИНКИ В ЯЧЕЙКУ
 public void AddPicture(string path, string cellAdress)
 {
     SelectCells(cellAdress, cellAdress);
     _p = _xlWorkSheet.Pictures(_misValue) as Excel.Pictures;
     _pic = _p.Insert(path, _misValue);
     _pic.Left = Convert.ToDouble(_range.Left);
     _pic.Top = Convert.ToDouble(_range.Top);
 }
Пример #3
0
 /// <summary>
 /// 插入图片
 /// </summary>
 /// <param name="sheet"> 工作表 </param>
 /// <param name="imageFilePath"> 图片的绝对路径 </param>
 /// <param name="rowNumber"> 单元格行号 </param>
 /// <param name="columnNumber"> 单元格列号 </param>
 /// <param name="width"> 图片的宽度 </param>
 /// <param name="height"> 图片的高度 </param>
 /// <returns></returns>
 public Xls.Picture AddImage(Xls.Worksheet sheet, string imageFilePath, int
                             rowNumber, int columnNumber, double width, double height)
 {
     Xls.Picture pic = this.AddImage(sheet, imageFilePath, rowNumber,
                                     columnNumber);
     pic.Width  = width;
     pic.Height = height;
     return(pic);
 }
Пример #4
0
 /// <summary>
 /// 插入图片
 /// </summary>
 /// <param name="sheet"> 工作表 </param>
 /// <param name="imageFilePath"> 图片的绝对路径 </param>
 /// <param name="rowNumber"> 单元格行号 </param>
 /// <param name="columnNumber"> 单元格列号 </param>
 /// <returns></returns>
 public Xls.Picture AddImage(Xls.Worksheet sheet, string imageFilePath, int
                             rowNumber, int columnNumber)
 {
     Xls.Range range = this.GetRange(sheet, rowNumber, columnNumber,
                                     rowNumber, columnNumber);
     range.Select();
     Xls.Pictures pics = sheet.Pictures(_missing) as Xls.Pictures;
     Xls.Picture  pic  = pics.Insert(imageFilePath, _missing);
     pic.Left = (double)range.Left;
     pic.Top  = (double)range.Top;
     return(pic);
 }
Пример #5
0
        public void InsertPicture(int iRowStart, int iColStart, string imgPath, double imgWidth, double imgHeight)
        {
            object misValue = System.Reflection.Missing.Value;

            Excel.Range    rangeObj         = (Excel.Range)worksheet.Cells[iRowStart, iColStart];
            Excel.Pictures imgObjCollection = worksheet.Pictures(misValue) as Excel.Pictures;
            Excel.Picture  imgObj           = null;
            imgObj        = imgObjCollection.Insert(imgPath, misValue);
            imgObj.Left   = Convert.ToDouble(rangeObj.Left) + (Convert.ToDouble(rangeObj.Width) - imgWidth) / 2;
            imgObj.Top    = Convert.ToDouble(rangeObj.Top);
            imgObj.Width  = imgWidth;
            imgObj.Height = imgHeight;
        }
Пример #6
0
        /// <summary>
        /// Chn 插入图片
        /// </summary>
        /// <param name="workSheet"></param>
        /// <param name="picturePath"></param>
        /// <param name="picLeft"></param>
        /// <param name="picTop"></param>
        /// <returns></returns>
        public static Excel.Picture InsertPictureByPicture(this Excel.Worksheet workSheet, string picturePath, float picLeft, float picTop)
        {
            Size picSize   = ImageHelper.GetDimensions(picturePath);
            int  picWidth  = picSize.Width;
            int  picHeight = picSize.Height;

            Excel.Pictures pics = (Excel.Pictures)workSheet.Pictures(Type.Missing);
            Excel.Picture  pic  = pics.Insert(picturePath, Type.Missing);

            pic.Left   = (double)picLeft;
            pic.Top    = (double)picTop;
            pic.Width  = (double)picWidth;
            pic.Height = (double)picHeight;

            return(pic);
        }
Пример #7
0
 //«јѕ»—№  ј–“»Ќ » ¬ я„≈… ”
 public void WritePictureToCell(string path)
 {
     p = xlWorkSheet.Pictures(misValue) as Excel.Pictures;
         pic = p.Insert(path, misValue);
         pic.Left = Convert.ToDouble(range.Left);
         pic.Top = Convert.ToDouble(range.Top);
 }
Пример #8
0
 //ЗАПИСЬ КАРТИНКИ В ЯЧЕЙКУ
 public void WritePictureToCell(string path)
 {
     _p = _xlWorkSheet.Pictures(_misValue) as Excel.Pictures;
     _pic = _p.Insert(path, _misValue);
     _pic.Left = Convert.ToDouble(_range.Left);
     _pic.Top = Convert.ToDouble(_range.Top);
 }