当前位置: 代码迷 >> PB >> 急导入excel文件后字符有?号解决办法
  详细解决方案

急导入excel文件后字符有?号解决办法

热度:89   发布时间:2016-04-29 09:55:45.0
急,导入excel文件后字符有?号
excel文件的字体为lucida   handwriting,我导入数据的原理是先把excel文件转成txt再导入数据窗口,导入数据窗口后会有些字符变成?号。我试过了,直接从excel中另存为txt文件时那些字符就会变成问号,怎样解决这个问题,让数据窗口按excel那样显示数据?

------解决方案--------------------
你是怎么导入的?是用dw_employee.ImportFile( "D:\EMPLOYEE.TXT "),还是用OleObject?


string ls_pathname, ls_filename, ls_cell
long ll_rtn, ll_rowno, ll_colno
integer li_row_1, li_row_2, i
//从excel文件获得数据
ole1= CREATE OLEObject
ole1.ConnectTonewObject( "Excel.application ")
//选择要导入数据的EXCEL文件
ll_rtn = getfileopenname( '打开文件 ',ls_pathname,ls_filename, 'XLS ', 'EXCEL文件(*.xls),*.xls ')
//ls_pathname = "D:\21_da\9354621s.xls "
if ll_rtn <> 1 then return
ole1.workbooks.open(ls_pathname,0,0)
ole1.visible = true

dw_2.reset()
SetPointer(HourGlass!)
//获取EXCEL单元格数据 ===================================
//ls_cell = ole1.workbooks[1].worksheets[1].cells(ll_rowno,ll_colno).value

////获取EXCEL单元格数据
//ls_cell = ole1.application.activeworkbook.worksheets(1).cells(1,1).value
////...
////处理后再写回excel
//ole1.application.activeworkbook.worksheets(2).cells(1,1).value=sle_1.text
////...

i = 5 //从Sheet2的第5行开始
ls_cell = string(ole1.application.activeworkbook.worksheets(2).cells(i,1).value)
do while trim(ls_cell) <> ' '
if upper(trim(ls_cell)) = 'Y ' then
li_row_2 = dw_2.insertrow(0)
ls_cell = string(ole1.application.activeworkbook.worksheets(1).cells(28,2).value) //sheet1 第28行,第2列
dw_2.setitem(li_row_2, "name_2 ", ls_cell)
ls_cell = string(ole1.application.activeworkbook.worksheets(2).cells(i,26).value) //sheet2 第i行,第26列
dw_2.setitem(li_row_2, "b_s_to_address_b ", ls_cell)
ls_cell = string(ole1.application.activeworkbook.worksheets(2).cells(i,27).value) //sheet2
dw_2.setitem(li_row_2, "b_n_fr_address_a ", ls_cell)
end if
i = i + 1
ls_cell = string(ole1.application.activeworkbook.worksheets(2).cells(i,1).value)
loop
SetPointer(Arrow!)

ole1.activeworkbook.close(false)
ole1.Application.quit
ole1.DisconnectObject()
DESTROY ole1
------解决方案--------------------
unicode倒入需要pb10以上,同时,你的后台数据库也要支持unicode。
  相关解决方案