zoukankan      html  css  js  c++  java
  • 将图片导出到Excel

     1 static void ExportImageToExcel(Args _args)
     2 {
     3        container ImaPos;
     4        COM comWorksheet;
     5        COM comShapes;
     6        COM comCells;
     7        COM comFont;
     8        COM comPageSetup;
     9        SysExcelWorksheet sheet;
    10        SysExcelApplication excel;
    11        SysExcelWorkbooks books;
    12        SysExcelWorkbook book;
    13        SysExcelWorksheets sheets;
    14        SysExcelCells cells;
    15        COMVariant variant = new COMVariant();
    16        COMVariant xpos = new COMVariant();
    17        COMVariant ypos = new COMVariant();
    18        COMVariant state = new COMVariant();
    19        COMVariant width = new COMVariant();
    20        COMVariant height = new COMVariant();
    21  
    22        image MyImage=new image();
    23        str 200 FileName;
    24        container newPos;
    25        int _nheight;
    26        real _ywidth,_yheight,curRow,curCol;
    27        ;
    28        curCol=1;
    29        _ywidth=1;
    30        _yheight=1;
    31        FileName='D:\\My Pictures\\Good Pic\\1600FG100_013.jpg';
    32        if (FileName)
    33        {
    34               excel = SysExcelApplication::construct();
    35               books = excel.workbooks();
    36               book = books.add();
    37               sheets = book.worksheets();
    38               sheet = sheets.itemFromNum(1);
    39  
    40               cells=sheet.cells();
    41               variant.int(-4167);
    42               comWorkSheet=sheet.comObject();
    43  
    44               comPageSetup = comWorkSheet.PageSetup();
    45               comPageSetup.LeftMargin(28);
    46               comPageSetup.RightMargin(28);
    47  
    48               comCells=comWorkSheet.Cells();
    49               comFont=comCells.Font();
    50               comFont.size(9);
    51  
    52               comCells.rowheight(16.5);
    53               comCells.ColumnWidth(8.435);
    54  
    55        }
    56        MyImage.loadImage(FileName);
    57        try
    58        {
    59               variant.bStr(FileName);
    60               xpos.int(1);
    61               ypos.int(1);
    62               state.int(2);
    63               width.int(MyImage.width());
    64               height.int(MyImage.height());
    65               comShapes = comWorkSheet.shapes();
    66               comShapes.addPicture(variant,1,1,_ywidth,_yheight,width,height);
    67        }
    68        catch(Exception::Error)
    69        {
    70               comWorkSheet.close();
    71               excel.quit();
    72        }
    73        excel.visible(true);
    74 }
  • 相关阅读:
    Bitstream or PCM?
    centos7安装Redis-3.2.8
    【生肉】【不义联盟
    ES6中Map数据结构学习笔记
    机器学习基石入门
    2019/5/9 长难句
    文件遍历选取脚本
    [JS奇怪的世界]No.55 危險小叮嚀:陣列與for in
    OpenGL Panorama Player
    吴裕雄--天生自然MySQL学习笔记:MySQL 连接
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2663276.html
Copyright © 2011-2022 走看看