当前位置:首页教育技巧excel技巧excel筛选

ascii怎么转excel表格

减小字体 增大字体 2025-01-02 12:58:33


1.

给你个我n年前写过的函数:

Public Function ColToChr(col As Integer) As String

'*********************************************************

'这个函数是将列数 转化成 excel里相对应的 列的标志字符串

'如第1列对应A, 第2列对应B。。.第27列对应AA

'输入col是excel的列,输出coltochr是相对应的列的标志字符串

'*********************************************************

On Error GoTo eHand

Dim int_D As Integer

Dim int_F As Integer

int_F = col Mod 26

If int_F = 0 Then int_F = 26

int_D = col \ 27

If int_D >0 Then

ColToChr = Chr(64 + int_D) & Chr(64 + int_F)

Else

ColToChr = Chr(64 + int_F)

End If

Exit Function

eHand:

MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "错误"

End Function

----------------

给单元格赋值这么做:

ActiveSheet.Cells(1,1)=10 ' A1设置为10

2.PB SaveAsAscii导出EXCEL是空白的,代码如下: 本机正常导出,有

语法本身没有错误,可能还是运行环境的原因。

很多网上下载的office,导入导出的时候就是会出现问题。可以选择使用其他的导出方式,比如用uo或者自定义输出函数!f_saveasexcel(dw_1,ls_err) 。

函数代码:integer li_rtn,ii,li_asc string ls_name,ls_pathname boolean lb_exist long numcols,c,r int ret string ls_colname,ls_text,ls_modistr,ls_col string ls_s,ls_temp[] long ll_bupper,ll_blower,ll_j OLEObject lx_excel if datawin.RowCount() err = "请先检索数据再导出至Excel!" return false//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 = datawin.SaveAsAscii(ls_pathname) if li_rtn 1 then err = "导出数据失败!" return false//error end if else err = "请选择要导出的路径!" return false//error end if else err = "已取消输出!" return false end if//通过ole直接操作excel lx_excel = CREATE OLEObject //连接excel IF lx_excel.ConnectToNewObject("excel.application") 0 THEN err = "OLE连接Excel错误!" return false END IF//打开导出Excel文件 lx_excel.workbooks.open(ls_pathname)//设置表格框 lx_excel.Worksheets(1).UsedRange.Borders.LineStyle = 1//首行粗体 lx_excel.Worksheets(1).rows(1).Font.Bold = True//首行单元格水平居中 lx_excel.Worksheets(1).rows(1).HorizontalAlignment = -4108//首行单元格垂直居中 lx_excel.Worksheets(1).rows(1).VerticalAlignment = -4108//调整Excel行高,列宽 lx_excel.Worksheets(1).Cells.EntireColumn.AutoFit lx_excel.Worksheets(1).Cells.EntireRow.AutoFit//所有列设置成文件格式显示 12-07 lx_excel.Worksheets(1).Range("A1:W8992").NumberFormatLocal = "@" //不进行提示 lx_excel.DisplayAlerts = false//保存表格 lx_excel.ActiveWorkbook.saveas(ls_pathname,-4143)//关闭打开的Excel lx_excel.ActiveWorkbook.close//退出 lx_excel.quit err = "导出数据成功!" return true//success。

评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分)

【免责声明】本站信息来自网友投稿及网络整理,内容仅供参考,如果有错误请反馈给我们及时更正,对文中内容的真实性和完整性本站不提供任何保证,不承但任何责任。
版权所有:学窍知识网 Copyright © 2011-2025 www.at317.com All Rights Reserved .