excel - 由于行数限制为 65,000,Microsoft Access 导出到 excel 文件时出错
问题描述
将我的 Microsoft 访问数据导出到 Excel 文件时遇到问题。
它给了我一个错误信息:
您选择的记录多于一次可以复制到剪贴板上的记录。将记录分成两组或更多组,然后一次复制并粘贴一组。一次可以粘贴的最大记录数约为 65,000。
我正在使用的代码:
FileCopy "S:\Users\File\Deposit.xls", strs & "\Deposit.xls"
解决方案
尝试这个:
Select External data
Got to Export
Hit Excel
You will be given a choice to select the destination for your data
Select where you want to save your exported data
In the Specify Report Options Area- you have the option to select and tick Export Data With Formatting And Layout
You also have the option to open the destination file after the export operation is complete- tick if you want to utilise this option
Hit OK
You may now get the above error at this stage if you have ticked the Export Data With Formatting And Layout Option and are trying to export more than 65,000 data lines
When the data is exported you can then hit Close
使用 VBA:
Sub transSpread()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"tblSales", "C:\Sales.xls"
MsgBox "Sales spreadsheet created"
End Sub
或者:
Option Compare Database
Option Explicit
' be sure to select Microsoft Excel Object Library in the References dialog box
Public myExcel As Excel.Application
Sub CopyToExcel()
Dim conn As ADODB.Connection
Dim myRecordset As ADODB.Recordset
Dim wbk As Excel.Workbook
Dim myWorksheet As Excel.Worksheet
Dim StartRange As Excel.Range
Dim strConn As String
Dim i As Integer
Dim f As Variant
On Error GoTo ErrorHandler
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurrentProject.Path & "\mydb.mdb"
Set conn = New ADODB.Connection
Set myRecordset = New ADODB.Recordset
With myRecordset
.Open "Employees", strConn, _
adOpenKeyset, adLockOptimistic
End With
Set myExcel = New Excel.Application
Set wbk = myExcel.Workbooks.Add
Set myWorksheet = wbk.ActiveSheet
myExcel.Visible = True
i = 1
With myRecordset
For Each f In .Fields
With myWorksheet
.Cells(1, i).Value = f.Name
i = i + 1
End With
Next
End With
Set StartRange = myWorksheet.Cells(2, 1)
StartRange.CopyFromrecordset myRecordset
myRecordset.Close
Set myRecordset = Nothing
myWorksheet.Columns.AutoFit
wbk.Close SaveChanges:=True, _
FileName:="C:\ExcelFile.xls"
myExcel.Quit
Set conn = Nothing
Exit Sub
ErrorHandler:
MsgBox Err.Description, vbCritical, _
"Automation Error"
Set myExcel = Nothing
Exit Sub
End Sub
推荐阅读
- python - 如果满足某些条件,则比较整行是否相等
- html - 即使使用相同的 CSS,顶部和底部的网站导航栏也无法正常工作
- javascript - 不能在nodejs的客户端产生错误
- node.js - Next.js - getInitialProps 中的 axios 返回 404
- c# - windows7 c#如何识别物理和虚拟网络适配器
- php - CodeIgniter 4 只有默认路由 / 是可访问的,如果我在我的 Routes.php 中定义,则没有其他路由可用。我正在使用 ubuntu
- java - 在主线程中保留一些进程,直到另一个线程完成其任务
- python - 使用 Python 发送和接收文件:FastAPI 和请求
- r - 根据来自另一个数据集的列计算统计数据(例如总和、平均值...)
- java - LWIP STM32CubeF7 与 TCP 以太网通信到 Java URL 连接类应用程序