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 }
  • 相关阅读:
    Java vs C++ 基础异同比较
    2. 数组
    1. 数据结构概述
    动态规划专题:LeetCode 完全平方数
    动态规划专题:LeetCode 乘积最大子数组
    动态规划专题:LeetCode连续数列
    动态规划专题:LeetCode 按摩师
    3. 无重复字符的最长子串
    字典树(前缀树/后缀树)
    10. 排序算法思想概述及总结(精华)
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2663276.html
Copyright © 2011-2022 走看看