求救,数据窗口打印的奇怪问题
这段程序实现将数据窗口数据转换出来在word中打印,在某些应用中无法转换标题头文字,显示为?,但在某些应用中可以,(标题头文字为宋体9号)不知道大家有没有遇到过相似问题,相关代码如下:
//得到数据窗口数据的列数与行数(行数应该是数据行数 + 1)
ll_colnum = ll_num
ll_rownum = dw_2.rowcount() + 1
ole_object.Documents.Add()
ole_object.ActiveDocument.Tables.Add(ole_object.Selection.Range, ll_rownum, ll_colnum)
string ls_colname
integer i,j,k
for i = 1 to ll_colnum
//得到标题头的名字
ls_value = ls_objtag[i]
ole_object.Selection.TypeText(ls_value)
for k = 1 to f_cncharnum(ls_value)
ole_object.Selection.TypeBackspace()
next
ole_object.Selection.MoveRight(wdCell)
next
dw_2.setredraw(false)
ole_object.Selection.MoveLeft(wdCell)
string column_name
for i = 2 to ll_rownum
for j = 1 to ll_colnum
column_name = ls_objs[j]
if dw_2.Describe(column_name + '.type') = 'column' then
ls_value = dw_2.Describe("Evaluate('LookupDisplay("+column_name+")',"+string(i - 1)+")")
end if
if dw_2.Describe(column_name + '.type') = 'compute' then
ls_value = dw_2.Describe("Evaluate('" + dw_2.Describe(column_name + '.expression') + "',"+string(i - 1)+")")
end if
ole_object.Selection.MoveRight(wdCell)
ole_object.Selection.TypeText(ls_value)
for k = 1 to f_cncharnum(ls_value)
ole_object.Selection.TypeBackspace()
next
next
next
dw_2.setredraw(true)
constant long wdFormatDocument = 0
SetPointer(oldpointer)
其中f_cncharnum代码如下:
//用途:返回一个字符串中汉字的个数
//输入:astring - string,给定的字符串
//返回值:li_num - integer 给定的字符串中汉字的个数
//注意:1、此方法基于汉字的国际汉字库区位编码的有效性,不符合此编码的系统此函数无效
//2、若汉字串含有非汉字字符,如图形符号或有ASCII码,则这些汉字字符将保持不变
string ls_ch
string ls_SecondSectTable //存入所有国标二级汉字读音
integer li_num = 0 // 返回值
integer i,j
for i = 1 to len(aString)
ls_ch = Mid(aString,i,1)
if Asc(ls_ch) >= 128 then // 是汉字
li_num++
i = i+1
end if
next
return li_num
谢谢!