转两列 或多列相同的数据到EXCEL

来源:互联网 发布:根据ip查域名 编辑:程序博客网 时间:2024/05/16 18:15
double jpgsize
string pictname,aa,ff,mcountry
long i=1,k,m,b,numrows,f,flg
numrows=dw_2.rowcount()
 

xls=xlapp.application.activeworkbook
xlsub=xlapp.application.activeworkbook.worksheets[1]
 
numrows=dw_2.rowcount()
K=CEILING(numrows/18)
xls=xlapp.application.activeworkbook
xlsub=xlapp.application.activeworkbook.worksheets[1]
for i=1 to K - 1
  b=99*i+1
  aa='A'+string(B)
    xlapp.Application.range("A1:E99").Select
  xlapp.Application.Selection.Copy
  xlapp.Application.range(AA).Select
    xlapp.Application.Selection.Insert()
next
 
 
 
int rows,rowset,addrow,cloumnset,addcloumn
rowset=2
cloumnset=2
addrow=11
addcloumn=3
 
for i=1 to numrows
 //left side
 if mod(i,2)=1 then                                         //转i=奇数的数据
  cloumnset=2                                             //设置第一个固定的列
 if mid(dw_2.object.q_qsheetitem_itemnumber[i],3,1) >='0' and mid(dw_2.object.q_qsheetitem_itemnumber[i],3,1)<='9' then
      xlsub.Cells[rowset+1,cloumnset]=mid(dw_2.object.q_qsheetitem_itemnumber[i],2)
    else
    xlsub.Cells[rowset+1,cloumnset]=mid(dw_2.object.q_qsheetitem_itemnumber[i],3)
    end if
  
  xlsub.Cells[rowset+4,cloumnset]=dw_2.object.q_qsheetitem_briefdesc[i]
      xlsub.Cells[rowset+6,cloumnset]=round(dw_2.object.q_qsheetitem_price_fob[i],4)
  xlsub.Cells[rowset+7,cloumnset]=round(dw_2.object.q_qsheetitem_price_elc[i],4)
      xlsub.Cells[rowset+8,cloumnset]=dw_2.object.q_qsheetitem_typepackag[i]
 end if
 
 if mod(i,2)=0 then                                             //转i=偶数的数据
  cloumnset=cloumnset+addcloumn                               //设置第二个固定的列
      if mid(dw_2.object.q_qsheetitem_itemnumber[i],3,1) >='0' and mid(dw_2.object.q_qsheetitem_itemnumber[i],3,1)<='9' then
      xlsub.Cells[rowset+1,cloumnset]=mid(dw_2.object.q_qsheetitem_itemnumber[i],2)
    else
    xlsub.Cells[rowset+1,cloumnset]=mid(dw_2.object.q_qsheetitem_itemnumber[i],3)
    end if
  
  xlsub.Cells[rowset+4,cloumnset]=dw_2.object.q_qsheetitem_briefdesc[i]
      xlsub.Cells[rowset+6,cloumnset]=round(dw_2.object.q_qsheetitem_price_fob[i],4)
  xlsub.Cells[rowset+7,cloumnset]=round(dw_2.object.q_qsheetitem_price_elc[i],4)
      xlsub.Cells[rowset+8,cloumnset]=dw_2.object.q_qsheetitem_typepackag[i]
  rowset=rowset+addrow  
 end if 
next 
//转多例数据到EXCEL(4例数据)
int xset,yset,x1,y1,x2,rows,xpage,pp
x1=18;y1=3;rows=1;xset=16;yset=2;x2=19;pp=12 
xpage=0
long ll_left=67.6,ll_top=50.2,li_times=1
long px,py,pxset,pyset
px=270;py=315
for i=1 to numrows
 if mod(i,4)=1 then
  yset=2
  xset=16
  pxset=10
  pyset=10  
  xset=xset+x1*( rows - 1)
  pxset=pxset+px*( rows - 1) 
  rows=rows+1 
 else
  
  yset=yset+y1 
  pyset=pyset+py
 end if
 
 //write data   (item and photo)
//write item
 if mid(dw_3.object.q_qsheetitem_itemnumber[i],3,1) >='0' and mid(dw_3.object.itemnumber[i],3,1)<='9' then
   xlsub.Cells[xset,yset]=mid(dw_3.object.itemnumber[i],2)
   else
   xlsub.Cells[xset,yset]=mid(dw_3.object.itemnumber[i],3)
  
 end if    
//write photo                                                                                         
  pictname=dw_3.object.photoname[i]
    if pictname<>'' and not(isnull(pictname)) then
    if flg = 0 then flg = photoexist(pictname)
      if FILEEXISTS(pictname) = true then
         xlapp.Application.ActiveSheet.Pictures.Insert(string(pictname)).select
       xlapp.Application.Selection.ShapeRange.height=120
     xlapp.Application.Selection.ShapeRange.Left=pyset
     xlapp.Application.Selection.ShapeRange.Top=pxset
  end if
 end if
 
next
原创粉丝点击