网站首页 > 文章中心 > 其它

vb.net导出xls科学计数的简单介绍

作者:小编 更新时间:2023-09-10 10:38:49 浏览量:338人看过

VB导出excel的代码存在的问题,只能导出当前datagrid显示记录,且导出的身份证很多为科学计数法,怎么办

我看了一下你的代码就是 导出当前datagrid显示记录

Do While DataGrid1.Row = 0

If i = DataGrid1.Row Then Exit Do

i = DataGrid1.Row '得到DataGrid1当前行

For j = 0 To DataGrid1.Columns.Count - 1 '在DataGrid1当前行各列中循环

With xlsApp

.Cells(1, j + 1).NumberFormatLocal = "@" '单元格设置为文本

end if

.Cells(DataGrid1.Row + 1, j + 1) = DataGrid1.Columns(j).Text '填充数据

End With

Next

DataGrid1.Row = DataGrid1.Row + 1

Loop

vb.net中datagradview 另存为excel文件的问题

Public Class Cls导入数据

Dim xlApp As New Excel.Application()

Dim xlBook As Excel.Workbook

Dim xlSheet As Excel.Worksheet

Dim A = "A"

Public Function 导出到Excel(ByVal Dt表 As DataTable) As Boolean

Dim rowIndex, colIndex As Integer

rowIndex = 1

colIndex = 0

xlBook = xlApp.Workbooks().Add

xlSheet = xlBook.Worksheets("sheet1")

Dim Table As New DataTable()

Table = CreaTable()

'将所得到的表的列名,赋值给单元格

Dim Col As DataColumn

Dim Row As DataRow

For Each Col In Table.Columns

colIndex = colIndex + 1

xlApp.Cells(1, colIndex) = Col.ColumnName

'得到的表所有行,赋值给单元格

For Each Row In Table.Rows

rowIndex = rowIndex + 1

xlApp.Cells(rowIndex, colIndex) = Row(Col.ColumnName)

With xlSheet

.Range(.Cells(1, 1), .Cells(1, colIndex)).Font.Name = "黑体"

'设标题为黑体字

.Range(.Cells(1, 1), .Cells(1, colIndex)).Font.Bold = True

'标题字体加粗

.Range(.Cells(1, 1), .Cells(rowIndex, colIndex)).Borders.LineStyle = 1

'设表格边框样式

With xlSheet.PageSetup

xlApp.SaveWorkspace()

MsgBox("保存完毕", MsgBoxStyle.Exclamation, "提示")

KillAllExcels()

'xlApp.Visible = True

End Function

Sub KillAllExcels()

Dim proc As System.Diagnostics.Process

For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")

proc.Kill()

End Sub

end class

asp.net导出excel 电话变科学计数法了

①.、在导出前对数据进行处理:在电话号码前+上一个"'"(单引号),这样excel就判定该数据是字符串,就不会转化成科学计数法了.

以上就是土嘎嘎小编为大家整理的vb.net导出xls科学计数的简单介绍vb.net导出xls科学计数的简单介绍相关咨询咨询主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章