程序员家园论坛软件开发PowerBuilder 我用那个dw2xls来把datawindow的数据另存为xls

1  /  1  页   1 跳转 查看:1311

我用那个dw2xls来把datawindow的数据另存为xls

我用那个dw2xls来把datawindow的数据另存为xls

怎么用excel打开这个文件时说文件格式无效?
 

回复:我用那个dw2xls来把datawindow的数据另存为xls

没用过dw2xls
 

回复:我用那个dw2xls来把datawindow的数据另存为xls

不会吧,rp啊rp
 

回复:我用那个dw2xls来把datawindow的数据另存为xls

efault3: efault3: 那个东东导出来的excel真的效果很差,准备放弃使用,自己写个,看来啥事情都都靠自己
 

回复:我用那个dw2xls来把datawindow的数据另存为xls

行数多了1500行,另存出来的xls文件没有数据,是一个没有工作表的工作薄
 

回复:我用那个dw2xls来把datawindow的数据另存为xls

行数多了1500行,另存出来的xls文件没有数据,是一个没有工作表的工作薄,
准确的说,也不是没有工作表,因为xls文件达到了好几M,打开xls文件时,工作表一闪就没有了,就也了xls的恢色工作背景。
 

回复:我用那个dw2xls来把datawindow的数据另存为xls

我反感的主要是那个东东设计时的思路,用位置来定位导入到excel中的布局,那样的东东还不如不导入到excel中呢?因为要手工再调整的话,工作量太大了,还是直接用saveasascii效果比较好,虽然格式没有了,但比调整那些列的位置和大小强
 

回复:我用那个dw2xls来把datawindow的数据另存为xls

我当初花钱买啦个dw2xls 。要啦200多大门。效果还可以。但不能导大量数据。会等死人的。上千笔就不太行啦。
 

回复:我用那个dw2xls来把datawindow的数据另存为xls

用这个
global type f_pbtoexcel from function_object
end type

forward prototypes
global function integer f_pbtoexcel (datawindow adw)
end prototypes

global function integer f_pbtoexcel (datawindow adw);integer li_rtn,ii,li_asc
string ls_name,ls_pathname
boolean lb_exist
if adw.RowCount()<1 then
MessageBox('提示信息','请先检索数据再导出至Excel!')
return -1 //error
end if
li_rtn=GetFileSaveName('保存文件',ls_pathname,ls_name,'xls','Excel文件(*.xls),*.xls')

if li_rtn=1 then
lb_exist = FileExists(ls_pathname)
IF lb_exist THEN
  li_rtn = MessageBox('保存', ls_pathname+'已经存在,是否覆盖?',Exclamation!, YesNo!)
end if
if li_rtn=1 then
//当文件存在用户选择覆盖,或是文件本就不存在时。注意变量li_rtn
  li_rtn=adw.SaveAsAscii(ls_pathname)
  if li_rtn=1 then
//  MessageBox('提示信息','导出数据成功!') 
  else
  MessageBox('错误信息','导出数据失败!')
  return -1 //error
  end if
else
  return -1 //error
end if
else
return -1
end if

/**********以下程序将导出的EXCEL英文标题替换为汉字*********/
long numcols , numrows , c, r
OLEObject xlapp , xlsub
int ret
numcols = long(adw.Object.DataWindow.Column.Count)
numrows = adw.RowCount()

// 产生oleobject的实例
xlApp = Create OLEObject

//连接ole对象
ret = xlApp.ConnectToNewObject( 'Excel.Sheet' )
if ret < 0  then
MessageBox('连接失败!','连接到EXCEL失败,请确认您的系统是否已经安装EXCEL!~r~n'&
+'错误代码:'+string(ret))
    return -1
end if
// 打开EXCEL文件
xlApp.Application.Workbooks.Open(ls_pathname)
////使文件可见
//xlApp.Application.Visible = true

// 得到活动工作表的引用,改善程序性能
xlsub = xlapp.Application.ActiveWorkbook.Worksheets[1]
string ls_colname,ls_text,ls_modistr,ls_col
//取字段名更改为对应的文本text值
FOR c=1 to numcols
ls_col='#'+string(c)+'.name'
ls_colname=adw.describe(ls_col)
ls_modistr=ls_colname+'_t.text'
ls_text=adw.describe(ls_modistr)
xlsub.cells[1,c]=ls_text
NEXT
xlapp.Application.DisplayAlerts = False
xlApp.Application.Quit()
xlApp.DisConnectObject()
Destroy xlapp
MessageBox('提示信息','导出数据成功!')

return 1 //success


end function
 
1  /  1  页   1 跳转

版权所有 程序员家园论坛   Sitemap

Powered by Discuz!NT 2.1.202    Copyright © 2001-2008 Comsenz Inc.
Processed in 0.046875 second(s) , 3 queries. 浙ICP备07502118号
返顶部