匯出圖片到Excel-完整Job

來源:互聯網
上載者:User

static void ExportImageToExcel(Args _args)

{

       container ImaPos;

       COM comWorksheet;

       COM comShapes;

       COM comCells;

       COM comFont;

       COM comPageSetup;

       SysExcelWorksheet sheet;

       SysExcelApplication excel;

       SysExcelWorkbooks books;

       SysExcelWorkbook book;

       SysExcelWorksheets sheets;

       SysExcelCells cells;

       COMVariant variant = new COMVariant();

       COMVariant xpos = new COMVariant();

       COMVariant ypos = new COMVariant();

       COMVariant state = new COMVariant();

       COMVariant width = new COMVariant();

       COMVariant height = new COMVariant();

 

       image MyImage=new image();

       str 200 FileName;

       container newPos;

       int _nheight;

       real _ywidth,_yheight,curRow,curCol;

       ;

       curCol=1;

       _ywidth=1;

       _yheight=1;

       FileName='D://My Pictures//Good Pic//1600FG100_013.jpg';

       if (FileName)

       {

              excel = SysExcelApplication::construct();

              books = excel.workbooks();

              book = books.add();

              sheets = book.worksheets();

              sheet = sheets.itemFromNum(1);

 

              cells=sheet.cells();

              variant.int(-4167);

              comWorkSheet=sheet.comObject();

 

              comPageSetup = comWorkSheet.PageSetup();

              comPageSetup.LeftMargin(28);

              comPageSetup.RightMargin(28);

 

              comCells=comWorkSheet.Cells();

              comFont=comCells.Font();

              comFont.size(9);

 

              comCells.rowheight(16.5);

              comCells.ColumnWidth(8.435);

 

       }

       MyImage.loadImage(FileName);

       try

       {

              variant.bStr(FileName);

              xpos.int(1);

              ypos.int(1);

              state.int(2);

              width.int(MyImage.width());

              height.int(MyImage.height());

              comShapes = comWorkSheet.shapes();

              comShapes.addPicture(variant,1,1,_ywidth,_yheight,width,height);

       }

       catch(Exception::Error)

       {

              comWorkSheet.close();

              excel.quit();

       }

       excel.visible(true);

}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.