zoukankan      html  css  js  c++  java
  • Export excel file

      1 void printSummary()
      2 {
      3     int                     i;
      4     Dimensions              m_Dimensions;
      5     #avifiles
      6     SysOperationProgress    simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, "Generating",100);
      7     ;
      8 
      9     excel  = SysExcelApplication::construct();
     10     excel.visible(true);
     11     books  = excel.workbooks();
     12     book   = books.add();
     13     Sheets = book.worksheets();
     14     sheet  = sheets.itemFromNum(1);
     15     sheet.name("Project summary report");
     16 
     17     styles = book.styles();
     18     style  = styles.add("StyleGlobal");
     19     font   = style.font();
     20     font.comObject().Size(9);
     21     sheet.columns().style("StyleGlobal");
     22 
     23     sheet.cells().item(1, 1).value("Project summary report");
     24     sheet  = excel.activeSheet();
     25     range  = sheet.range("A1");
     26     styles = book.styles();
     27     style  = styles.add("StyleTitle");
     28     font   = style.font();
     29     font.bold(true);
     30     font.comObject().Size(16);
     31     range.style("StyleTitle");
     32 
     33     sheet.cells().item(2, 1).value(strfmt("Period: %1..%2", mkdate(1, 1, g_Year), mkdate(31, 12, g_Year)));
     34     sheet.cells().item(2, 14).value("Currency: USD");
     35     sheet  = excel.activeSheet();
     36     range  = sheet.range("A2:N2");
     37     styles = book.styles();
     38     style  = styles.add("StylePeriod");
     39     font   = style.font();
     40     font.bold(true);
     41     font.comObject().Size(12);
     42     range.style("StylePeriod");
     43 
     44     sheet.cells().item(3, 1).value("Number");
     45     sheet.cells().item(3, 2).value("Description");
     46     sheet.cells().item(3, 3).value(g_Mth1);     sheet.cells().item(3, 4).value(g_Mth2);
     47     sheet.cells().item(3, 5).value(g_Mth3);     sheet.cells().item(3, 6).value(g_Mth4);
     48     sheet.cells().item(3, 7).value(g_Mth5);     sheet.cells().item(3, 8).value(g_Mth6);
     49     sheet.cells().item(3, 9).value(g_Mth7);     sheet.cells().item(3, 10).value(g_Mth8);
     50     sheet.cells().item(3, 11).value(g_Mth9);    sheet.cells().item(3, 12).value(g_Mth10);
     51     sheet.cells().item(3, 13).value(g_Mth11);   sheet.cells().item(3, 14).value(g_Mth12);
     52     sheet  = excel.activeSheet();
     53     range  = sheet.range("A3:N3");
     54     styles = book.styles();
     55     style  = styles.add("StyleHeader");
     56     font   = style.font();
     57     font.bold(true);
     58     font.comObject().Size(10);
     59     range.style("StyleHeader");
     60 
     61     sheet.cells().range("C3").numberFormat("mmm-yy");   sheet.cells().range("D3").numberFormat("mmm-yy");
     62     sheet.cells().range("E3").numberFormat("mmm-yy");   sheet.cells().range("F3").numberFormat("mmm-yy");
     63     sheet.cells().range("G3").numberFormat("mmm-yy");   sheet.cells().range("H3").numberFormat("mmm-yy");
     64     sheet.cells().range("I3").numberFormat("mmm-yy");   sheet.cells().range("J3").numberFormat("mmm-yy");
     65     sheet.cells().range("K3").numberFormat("mmm-yy");   sheet.cells().range("L3").numberFormat("mmm-yy");
     66     sheet.cells().range("M3").numberFormat("mmm-yy");   sheet.cells().range("N3").numberFormat("mmm-yy");
     67 
     68     i = 3;
     69     while select m_Dimensions
     70         order by m_Dimensions.Num asc
     71         where m_Dimensions.DimensionCode == SysDimension::Department    &&
     72               m_Dimensions.Num           != "P9999"
     73     {
     74         g_TotalPercent = (i - 2) / g_TotalRecNum * 100;
     75         simpleprogress.setCaption("Generating data, pease wait...");
     76         simpleProgress.incCount(str2int64(strfmt("%1", g_TotalPercent)));
     77         simpleprogress.setText(strfmt("Generated: %1%", g_TotalPercent));
     78         simpleprogress.update(true);
     79     
     80         i++;
     81         sheet.cells().item(i, 1).value(m_Dimensions.Num);
     82         sheet.cells().item(i, 2).value(m_Dimensions.Description);
     83         sheet.cells().item(i, 3).value(element.sumProject(m_Dimensions.Num, g_Mth1));
     84         sheet.cells().item(i, 4).value(element.sumProject(m_Dimensions.Num, g_Mth2));
     85         sheet.cells().item(i, 5).value(element.sumProject(m_Dimensions.Num, g_Mth3));
     86         sheet.cells().item(i, 6).value(element.sumProject(m_Dimensions.Num, g_Mth4));
     87         sheet.cells().item(i, 7).value(element.sumProject(m_Dimensions.Num, g_Mth5));
     88         sheet.cells().item(i, 8).value(element.sumProject(m_Dimensions.Num, g_Mth6));
     89         sheet.cells().item(i, 9).value(element.sumProject(m_Dimensions.Num, g_Mth7));
     90         sheet.cells().item(i, 10).value(element.sumProject(m_Dimensions.Num, g_Mth8));
     91         sheet.cells().item(i, 11).value(element.sumProject(m_Dimensions.Num, g_Mth9));
     92         sheet.cells().item(i, 12).value(element.sumProject(m_Dimensions.Num, g_Mth10));
     93         sheet.cells().item(i, 13).value(element.sumProject(m_Dimensions.Num, g_Mth11));
     94         sheet.cells().item(i, 14).value(element.sumProject(m_Dimensions.Num, g_Mth12));
     95     }
     96 
     97     //Summary all
     98     i++;
     99     sheet.cells().item(i, 2).value("All in total:");
    100     sheet.cells().item(i, 3).value(g_Sum1);
    101     sheet.cells().item(i, 4).value(g_Sum2);
    102     sheet.cells().item(i, 5).value(g_Sum3);
    103     sheet.cells().item(i, 6).value(g_Sum4);
    104     sheet.cells().item(i, 7).value(g_Sum5);
    105     sheet.cells().item(i, 8).value(g_Sum6);
    106     sheet.cells().item(i, 9).value(g_Sum7);
    107     sheet.cells().item(i, 10).value(g_Sum8);
    108     sheet.cells().item(i, 11).value(g_Sum9);
    109     sheet.cells().item(i, 12).value(g_Sum10);
    110     sheet.cells().item(i, 13).value(g_Sum11);
    111     sheet.cells().item(i, 14).value(g_Sum12);
    112 
    113     sheet  = excel.activeSheet();
    114     styles = book.styles();
    115     style  = styles.add("StyleSum");
    116     font   = style.font();
    117     font.bold(true);
    118     range  = sheet.range(strfmt("A%1:N%2", i, i));
    119     range.style("StyleSum");
    120 
    121     styles = book.styles();
    122     style  = styles.add("StyleAlign");
    123     style.horizontalAlignment(-4152);
    124     font   = style.font();
    125     font.bold(true);
    126 
    127     sheet.cells().range("A1:B1").comObject().merge();
    128     sheet.cells().range("A2:B2").comObject().merge();
    129     sheet.cells().range("L2:N2").comObject().merge();
    130     sheet.cells().range("L2:N2").style("StyleAlign");
    131     sheet.columns().autoFit();
    132 
    133     info("Print project summary report successful!");
    134 }
  • 相关阅读:
    uva 10369 Arctic Network
    uvalive 5834 Genghis Khan The Conqueror
    uvalive 4848 Tour Belt
    uvalive 4960 Sensor Network
    codeforces 798c Mike And Gcd Problem
    codeforces 796c Bank Hacking
    codeforces 768c Jon Snow And His Favourite Number
    hdu 1114 Piggy-Bank
    poj 1276 Cash Machine
    bzoj 2423 最长公共子序列
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2659957.html
Copyright © 2011-2022 走看看