码迷,mamicode.com
首页 > 其他好文 > 详细

導出到Excel

时间:2014-08-16 17:01:50      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:des   style   os   io   for   ar   line   size   

void clicked()
{
#Excel
HWND HWND;
SysExcelApplication excel;
SysExcelWorkbooks books;
SysExcelWorkbook book;
SysExcelWorksheets sheets;
SysExcelWorksheet sheet;
SysExcelRange columns;
SysExcelRange column;
SysExcelCells cells;
SysExcelCell cell;
SysExcelStyle ExcelStyle;
SysExcelFont ExcelFont;
SysExcelFormatCondition FormatCondition;
CSM_DeliveryNoticeLine csm_dnline;
str rangestr;
com comPageSetup;
COM com;

inventtable IT;
int i = 0,j = 0;
int amountpackqty=0;
int amountqty=0;
CSM_GrossWeight CSM_GrossWeight;
CSM_NetWeight CSM_NetWeight;
excel = SysExcelApplication::construct();
books = excel.workbooks();
book = books.add();
Sheets = book.worksheets();
sheet = sheets.itemFromNum(1);
cells = sheet.cells();

sheet.name("sheet1");

super();

sheet.cells().item(1,1).value("砯场:"); // item(row,column)
sheet.cells().item(1,2).value(enum2str(CSM_DeliveryNoticeTable.ShippingDept));

sheet.cells().item(2,1).value("砯ら戳:");
sheet.cells().item(2,2).value(date2strusr(CSM_DeliveryNoticeTable.ShippingDate));
sheet.cells().item(2,3).value("め:");
sheet.cells().item(2,4).value(CSM_DeliveryNoticeTable.CustName);
Sheet.cells().item(2,5).value("ó礟:");
sheet.cells().item(2,6).value(CSM_DeliveryNoticeTable.PlateNumber);
Sheet.cells().item(2,7).value("耫腹:");
sheet.cells().item(2,8).value(CSM_DeliveryNoticeTable.ContainerNo);
Sheet.cells().item(2,9).value("─:");
sheet.cells().item(2,10).value(CSM_DeliveryNoticeTable.CSM_Port);

Sheet.cells().item(2,11).value("SIZE:");
sheet.cells().item(2,12).value(CSM_DeliveryNoticeTable.SIZE);
sheet.rows().item(1).comObject().RowHeight(21);
sheet.rows().item(2).comObject().RowHeight(20);
sheet.rows().item(3).comObject().RowHeight(20);
i = 3;
while select csm_dnline where csm_dnline.CSM_DeliveryNoticeId == CSM_DeliveryNoticeTable.CSM_DeliveryNoticeId
{
i++;
j++;
if(!sheet.cells().item(i-1,1).value().bStr())
{
Sheet.cells().item(i,1).value("");
Sheet.cells().item(i,2).value("砯腹");
Sheet.cells().item(i,3).value("嘿");
Sheet.cells().item(i,4).value("ン计");
Sheet.cells().item(i,5).value("计");
Sheet.cells().item(i,7).value("袖");
Sheet.cells().item(i,6).value("を");
Sheet.cells().item(i,8).value("瓣產");
Sheet.cells().item(i,9).value("腹");
Sheet.cells().item(i,10).value("兜腹");
Sheet.cells().item(i,11).value("珇礟");
Sheet.cells().item(i,12).value("厨闽虫腹");
sheet.rows().item(i).comObject().RowHeight(20);
i++;
}
if(i mod 27 == 0)
{
Sheet.cells().item(i,1).value("");
Sheet.cells().item(i,2).value("砯腹");
Sheet.cells().item(i,3).value("嘿");
Sheet.cells().item(i,4).value("ン计");
Sheet.cells().item(i,5).value("计");
Sheet.cells().item(i,7).value("袖");
Sheet.cells().item(i,6).value("を");
Sheet.cells().item(i,8).value("瓣產");
Sheet.cells().item(i,9).value("腹");
Sheet.cells().item(i,10).value("兜腹");
Sheet.cells().item(i,11).value("珇礟");
Sheet.cells().item(i,12).value("厨闽虫腹");
sheet.rows().item(i).comObject().RowHeight(17);
}
else
{
sheet.cells().item(i,1).value(csm_dnline.SalesId);
sheet.cells().item(i,2).value(csm_dnline.ItemId);
sheet.cells().item(i,3).value(csm_dnline.CDS_DES);
sheet.cells().item(i,4).value(csm_dnline.PackQty);
sheet.cells().item(i,5).value(csm_dnline.Qty);
sheet.cells().item(i,7).value(csm_dnline.CSM_GrossWeight);
sheet.cells().item(i,6).value(csm_dnline.CSM_NetWeight);
sheet.cells().item(i,8).value(csm_dnline.CountryId);
sheet.cells().item(i,9).value(csm_dnline.ContractNo);
sheet.cells().item(i,10).value(csm_dnline.CSM_LineNo);
sheet.cells().item(i,11).value(csm_dnline.Brand);
sheet.cells().item(i,12).value(csm_dnline.CSM_DeclareNum);
sheet.rows().item(i).comObject().RowHeight(20); //砞竚︽蔼
}
amountpackqty += csm_dnline.PackQty;
amountqty += csm_dnline.Qty;
CSM_GrossWeight += csm_dnline.CSM_GrossWeight;
CSM_NetWeight += csm_dnline.CSM_NetWeight;

}
Sheet.cells().item(i+1,3).value("羆璸:");
sheet.cells().item(i+1,4).value(amountpackqty);
sheet.cells().item(i+1,5).value(amountqty);
sheet.cells().item(i+1,7).value(CSM_GrossWeight);
sheet.cells().item(i+1,6).value(CSM_NetWeight);
sheet.rows().item(i+1).comObject().RowHeight(20);

rangestr = strfmt("A4:L%1",i+1); //砞竚娩絬彩
com = sheet.range(rangestr).comObject();
com = com.Borders();
com.LineStyle(1);

sheet.range("A:A").comObject().ColumnWidth(11);
sheet.range("B:b").comObject().ColumnWidth(11);
sheet.range("C:C").comObject().ColumnWidth(20);
sheet.range("D:D").comObject().ColumnWidth(8);
sheet.range("E:E").comObject().ColumnWidth(8);
sheet.range("F:F").comObject().ColumnWidth(8);
sheet.range("G:G").comObject().ColumnWidth(8);
sheet.range("H:H").comObject().ColumnWidth(6);
sheet.range("I:I").comObject().ColumnWidth(13);
sheet.range("J:J").comObject().ColumnWidth(5);
sheet.range("K:K").comObject().ColumnWidth(20);
sheet.range("L:L").comObject().ColumnWidth(15); //砞竚︽糴

sheet.cells().comObject().horizontalAlignment(3); //﹡い

com = sheet.comObject(); //纐粄绢ゴ
com = com.pagesetup();
com.Orientation(2);

excel.visible(true);

}

導出到Excel,布布扣,bubuko.com

導出到Excel

标签:des   style   os   io   for   ar   line   size   

原文地址:http://www.cnblogs.com/AllenFeng/p/3916531.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!