導出到Excel

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

时间: 2024-12-12 08:28:11

導出到Excel的相关文章

GridView導出Excel

1.aspx頁面需要添加:EnableEventValidation="false" 實例:<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false"  CodeFile="DefCheckDate.aspx.cs"    Inherits="WebAdmin_CustomRegister_Short

Saiku更改導出文件的文件名(十九)

Saiku更改導出文件的文件名 Saiku查询完数据之后,可以以excel,pdf,csv等格式将数据导出,这里我们来讲一下怎么更改导出的文件名. 找到对应的导出方法所在的js文件: saiku-server\tomcat\webapps\ROOT\js\saiku\views\WorkspaceToolbar.js 这里分别有三个方法导出不同形式的文件: export_xls export_csv export_pdf 我们主要更改里面的filename即可啦! 可以自定义filename,我

table導出excel | 後臺

第一種也是比較好的方法: String str=afwtHtml; FileWriter writer; try { writer = new FileWriter("D:\\logs\\nihao2.xls"); writer.write(str); writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } return "ExportFinished"; 第二

導出Excel方法

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.OleDb; using System.Windows.Forms; using System.Data; using System.Runtime.InteropServices; namespace WmsClient { public class Excel { public stat

C#根據當前DataGridView查詢數據導出Excel

private void btnsuggestinfo_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("單號", typeof(string)); dt.Columns.Add("項次", typeof(decimal)); dt.Columns.Add("項次預約數量", typeof(decimal)); dt.Column

wwwjustnet实现19908836661数据库出为Excel表格

数据库数据导出为excel表格,也可以说是一个很常用的功能了.毕竟不是任何人都懂数据库操作语句的. Python实现数据库一键导出为Excel表格.看看完成的效果吧. 数据源Python实现数据库一键导出为Excel表格导出结果 Python实现数据库一键导出为Excel表格依赖由于是Python实现的,所以需要有Python环境的支持:Python2.7.11我的Python环境是2.7.11.虽然你用的可能是3.5版本,但是思想是一致的. xlwtpip install xlwtMySQLd

導出數據庫表結構

SELECT 表名 = Case When A.colorder=1 Then D.name Else '' End, 表说明 = Case When A.colorder=1 Then isnull(F.value,'') Else '' End, 字段序号 = A.colorder, 字段名 = A.name, 字段说明 = isnull(G.[value],''), 标识 = Case When COLUMNPROPERTY( A.id,A.name,'IsIdentity')=1 The

Java分页下载

需求.提供公共的可以按照一定条件查询出结果,并提供将查询结果全部下载功能(Excel.CSV.TXT),由于一次性查出结果放到内存会占用大量内存.需要支持分页模式查询出所有数据. 实现思路 1.在公共的controller(BaseController)中增加下载方法 2.支持自定义分页查询方式.自定义表头和查询结果属性对应 @ResponseBody @RequestMapping("/exportExcel.json") public void exportExcel(HttpSe

Delphi 导出数据至Excel的7种方法【转】

转自:http://blog.csdn.net/zang141588761/article/details/52275948 一; delphi 快速导出excel uses ComObj,clipbrd; function ToExcel(sfilename:string; ADOQuery:TADOQuery):boolean; const xlNormal=-4143; var y : integer; tsList : TStringList; s,filename :string; a