📄 excel.jsp
字号:
<%@ page import="com.hexiesoft.utils.StringUtils"%>
<%@ page contentType="text/html; charset=GBK" %>
<%@ include file="/IncludeBeginMD.jsp" %>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFCell"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%
String BOL=DataConvert.toRealString(iPostChange,CurPage.getParameter("BOL"));
String BLNO=DataConvert.toRealString(iPostChange,CurPage.getParameter("BLNO"));
String Invoice=DataConvert.toRealString(iPostChange,CurPage.getParameter("Invoice"));
String PackList=DataConvert.toRealString(iPostChange,CurPage.getParameter("PackList"));
String Certificate=DataConvert.toRealString(iPostChange,CurPage.getParameter("Certificate"));
String wantworks=DataConvert.toRealString(iPostChange,CurPage.getParameter("wantworks"));
response.reset();
response.setContentType("application/msexcel");
response.setContentType("charset=GBK");
response.setHeader("Content-disposition", "inline;filename=PrintBolInvoicePack.xls");
HSSFWorkbook book = new HSSFWorkbook();
%>
<% HSSFSheet sheet = book.createSheet("BOL");
if(!BOL.equals("") )
{
String cAdd1="";
String cCity="" ;
String cPcode="";
String country="";
String shipdt="";
String carrier="";
String shname="";
String ordertype="";
String shadd1="";
String shadd2="";
String shadd3="";
String shadd4="";
String route="";
String declared ="";
String currency ="";
String verifyby ="";
double copnotes =0;
double copweight =0;
double copfoil =0;
double copFweight =0;
double copstrip =0;
double copSweight =0;
String alloy ="";
String bstrip ="";
double branotes =0;
double braweight =0;
double braFoil =0;
double braFweight =0;
double brastrip =0;
double braSweight =0;
boolean nextline =false;
String cweight ="";
double notes =0;
String gross ="";
String cName="WOLVERINE RATCLIFFS INC.";
String cProvst="ONTARIO";
ASResultSet rs=Sqlca.getASResultSet("select * from invoice where blno=" + BLNO);
if(rs.next() )
{
if(rs.getString("plant").equals("FERG"))
{
cAdd1="865 GARTSHORE STREET";
cCity="FERGUS" ;
cPcode="N1M 2W7" ;
}
else
{
cAdd1="10537 YONGE STREET" ;
cCity="RICHMOND HILL" ;
cPcode="L4C 3C5" ;
}
carrier=rs.getString("carrier");
shadd1=rs.getString("shadd1");
shadd2=rs.getString("shadd2");
shadd3=rs.getString("shadd3");
shadd4=rs.getString("shadd4");
route=rs.getString("route");
declared =rs.getString("declared");
currency =rs.getString("declared");
verifyby =rs.getString("verifyby");
gross =rs.getString("gross");
}
else
{
out.print("<script>alert('No shipment records to print');</script>");
}
//what country is customer from?
ASResultSet rsc=Sqlca.getASResultSet("select * from customer where account='" + rs.getString("account") + "' and subacct='" +rs.getString("subacct") + "'");
if(rsc.next() )
{
country=rsc.getString("country");
shname=rsc.getString("shname");
}
// * page header
ASResultSet rss=Sqlca.getASResultSet("select * from shipment where blno=" + BLNO);
if(rss.next() )
{
shipdt=rss.getString("shipdt");
ordertype=rss.getString("ordertype");
alloy =rss.getString("alloy");
notes = rss.getDouble("notes");
if(StringUtils.copper(alloy))
{
copnotes =copnotes +notes;
copweight =copweight +rss.getDouble("loaded")*(-1);
if(rss.getString("hscode").compareTo("7410.11.0000") ==0)
{
copfoil =copfoil +notes;
copFweight =copFweight +rss.getDouble("loaded")*(-1);
}
else
{
copstrip =copstrip +notes;
copSweight =copSweight +rss.getDouble("loaded")*(-1);
}
}else
{
if(StringUtils.nickel(alloy) )
{
bstrip ="NICKEL SILVER";
}
if(StringUtils.phos(alloy))
{
bstrip="PHOS BRONZE";
}
if(StringUtils.brass(alloy))
{
bstrip="BRASS STRIP";
}
branotes =branotes +notes;
braweight =braweight +rss.getDouble("loaded")*(-1);
if(rss.getString("hscode").compareTo("7410.12.0030") ==0)
{
braFoil =braFoil +notes;
braFweight =braFweight +rss.getDouble("loaded")*(-1);
}else
{
brastrip =brastrip +notes;
braSweight =braSweight +rss.getDouble("loaded")*(-1);
}
}
cweight =(rss.getString("islbs") =="0")?"LBS":"KGS";
}
for (int i=0;i<Integer.parseInt( (BOL=="")?"0":BOL);i++)
{
HSSFRow r1=sheet.createRow(i + 0);
HSSFCell r1c1=r1.createCell((short)0);
r1c1.setCellValue(BLNO);
HSSFRow r2=sheet.createRow(i + 1);
HSSFCell r1c2=r2.createCell((short)0);
r1c2.setCellValue( shipdt.substring(0,10) +" "+carrier);
HSSFRow r3=sheet.createRow(i + 2);
HSSFCell r1c3=r3.createCell((short)0);
r1c3.setCellValue(cName + " "+ shname);
if(!ordertype.trim() .equals("REG"))
{
HSSFRow r4=sheet.createRow(i + 3);
HSSFCell r1c4=r4.createCell((short)0);
r1c4.setCellValue(shname);
}
HSSFRow r5=sheet.createRow(i + 4);
HSSFCell r1c5=r5.createCell((short)0);
r1c5.setCellValue(cAdd1 +" "+ shadd1);
HSSFRow r6=sheet.createRow(i + 5);
HSSFCell r1c6=r6.createCell((short)0);
r1c6.setCellValue(cCity +" "+ cProvst);
HSSFRow r7=sheet.createRow(i + 6);
HSSFCell r1c7=r7.createCell((short)0);
r1c7.setCellValue(shadd2 +" "+ shadd3+" "+ shadd4);
HSSFRow r8=sheet.createRow(i + 7);
HSSFCell r1c8=r8.createCell((short)0);
r1c8.setCellValue(route);
if(country=="U")
{ HSSFRow r9=sheet.createRow(i + 8);
HSSFCell r1c9=r9.createCell((short)0);
r1c9.setCellValue("PBB GROUP");
}
HSSFRow r10=sheet.createRow(i + 9);
HSSFCell r1c10=r10.createCell((short)0);
r1c10.setCellValue(declared);
if(currency=="CA")
{
HSSFRow r11=sheet.createRow(i + 10);
HSSFCell r1c11=r11.createCell((short)0);
r1c11.setCellValue("CDN");
}
if(currency=="US")
{
HSSFRow r12=sheet.createRow(i + 11);
HSSFCell r1c12=r12.createCell((short)0);
r1c12.setCellValue("USA");
}
if(currency=="UK")
{
HSSFRow r13=sheet.createRow(i + 12);
HSSFCell r1c13=r13.createCell((short)0);
r1c13.setCellValue("STERLING");
}
if(currency=="EU")
{
HSSFRow r14=sheet.createRow(i + 13);
HSSFCell r1c14=r14.createCell((short)0);
r1c14.setCellValue("EUROS");
}
if(verifyby =="PROFORMA")
{
HSSFRow r15=sheet.createRow(i + 14);
HSSFCell r1c15=r15.createCell((short)0);
r1c15.setCellValue("PROFORMA");
}
if(copstrip > 0 )
{
HSSFRow r16=sheet.createRow(i + 15);
HSSFCell r1c16=r16.createCell((short)0);
r1c16.setCellValue(copstrip);
HSSFRow r17=sheet.createRow(i + 16);
HSSFCell r1c17=r17.createCell((short)0);
r1c17.setCellValue("COPPER STRIP");
HSSFRow r18=sheet.createRow(i + 17);
HSSFCell r1c18=r18.createCell((short)0);
r1c18.setCellValue( copSweight +" "+ cweight);
nextline =true;
}
if(copfoil > 0 )
{
if(nextline)
{
nextline =false;
}
HSSFRow r19=sheet.createRow(i + 18);
HSSFCell r1c19=r19.createCell((short)0);
r1c19.setCellValue( copfoil );
HSSFRow r20=sheet.createRow(i + 19);
HSSFCell r1c20=r20.createCell((short)0);
r1c20.setCellValue( "COPPER FOIL " );
HSSFRow r21=sheet.createRow(i + 20);
HSSFCell r1c21=r21.createCell((short)0);
r1c21.setCellValue( copFweight +" "+ cweight);
nextline =true;
}
if(branotes > 0 )
{
if(nextline)
{
nextline =false;
}
if(brastrip > 0 )
{
HSSFRow r22=sheet.createRow(i + 21);
HSSFCell r1c22=r22.createCell((short)0);
r1c22.setCellValue( brastrip );
HSSFRow r23=sheet.createRow(i + 22);
HSSFCell r1c23=r23.createCell((short)0);
r1c23.setCellValue( bstrip );
HSSFRow r24=sheet.createRow(i + 23);
HSSFCell r1c24=r24.createCell((short)0);
r1c24.setCellValue( braSweight+" "+ cweight );
nextline =true;
}
if(braFoil > 0 )
{
if(nextline)
{
nextline =false;
}
HSSFRow r25=sheet.createRow(i + 24);
HSSFCell r1c25=r25.createCell((short)0);
r1c25.setCellValue( braFoil );
HSSFRow r26=sheet.createRow(i + 25);
HSSFCell r1c26=r26.createCell((short)0);
r1c26.setCellValue("BRASS FOIL ");
HSSFRow r27=sheet.createRow(i + 26);
HSSFCell r1c27=r27.createCell((short)0);
r1c27.setCellValue( braFweight+" "+cweight );
}
}
HSSFRow r28=sheet.createRow(i + 27);
HSSFCell r1c28=r28.createCell((short)0);
r1c28.setCellValue( braFoil );
HSSFRow r29=sheet.createRow(i + 28);
HSSFCell r1c29=r29.createCell((short)0);
r1c29.setCellValue( gross+" "+cweight );
HSSFRow r30=sheet.createRow(i + 29);
HSSFCell r1c30=r30.createCell((short)0);
r1c30.setCellValue( " TO BE PREPAID " );
HSSFRow r31=sheet.createRow(i + 30);
HSSFCell r1c31=r31.createCell((short)0);
r1c31.setCellValue( " ALL LOADS MUST BE BLOCKED " );
HSSFRow r32=sheet.createRow(i + 31);
HSSFCell r1c32=r32.createCell((short)0);
r1c32.setCellValue( " WOLVERINE " +carrier );
HSSFRow r33=sheet.createRow(i + 32);
HSSFRow r34=sheet.createRow(i + 33);
}
}
%>
<% HSSFSheet sheet1 = book.createSheet("Invoice");
if(!Invoice.equals("") )
{
String cnconame="";
String cName="";
String cCity="";
String cProvst="";
String cTraffic="";
double gstrate=0;
String wght ="";
String ordertype ="";
boolean to_whouse=false;
boolean from_whouse=false;
String wblno ="";
String ttblno ="";
String prevcustpo ="";
double prevnet =0;
String posort ="";
String coils ="";
double nPOnet=0;
double nPOinv =0;
String invgst ="";
double nGST =0;
String custpo="";
String alloy="";
String contract="";
String islbs="";
String invunit="";
String canlbspr="";
double invextend=0;
String isimperial="";
String DESC="";
String mt_width="";
String mt_gauge="";
String custprod="";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -