我有一个巨大的PowerPivot表(839,726行),它太大了,无法复制粘贴到常规电子表格中。我已经尝试复制它,然后使用行data = read.table("clipboard", header = T)
将其直接读入R,但这些方法都不起作用。我想知道是否有一些附加组件或方法我可以用来将我的PowerPivot表导出为CSV或.xlsx?非常感谢
答案 0 :(得分:2)
答案 1 :(得分:0)
将PowerPivot表格导入Excel:
答案 2 :(得分:0)
另一种解决方案是
这是一个例子
答案 3 :(得分:0)
下面是纯Excel / VBA解决方案。这是从代码here改编而来使用FileSystemObject并一次写入1k行到文件。您需要添加Microsoft ActiveX数据对象库和Microsoft Scripting Runtime作为参考。
Option Explicit
Public FSO As New FileSystemObject
Public Sub ExportToCsv()
Dim wbTarget As Workbook
Dim ws As Worksheet
Dim rs As Object
Dim sQuery As String
'Suppress alerts and screen updates
With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
'Bind to active workbook
Set wbTarget = ActiveWorkbook
Err.Clear
On Error GoTo ErrHandler
'Make sure the model is loaded
wbTarget.Model.Initialize
'Send query to the model
sQuery = "EVALUATE <Query>"
Set rs = CreateObject("ADODB.Recordset")
rs.Open sQuery, wbTarget.Model.DataModelConnection.ModelConnection.ADOConnection
Dim CSVData As String
Call WriteRecordsetToCSV(rs, "<ExportPath>", True)
rs.Close
Set rs = Nothing
ExitPoint:
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
Set rs = Nothing
Exit Sub
ErrHandler:
MsgBox "An error occured - " & Err.Description, vbOKOnly
Resume ExitPoint
End Sub
Public Sub WriteRecordsetToCSV(rsData As ADODB.Recordset, _
FileName As String, _
Optional ShowColumnNames As Boolean = True, _
Optional NULLStr As String = "")
'Function returns a string to be saved as .CSV file
'Option: save column titles
Dim TxtStr As TextStream
Dim K As Long, CSVData As String
'Open file
Set TxtStr = FSO.CreateTextFile(FileName, True, True)
If ShowColumnNames Then
For K = 0 To rsData.Fields.Count - 1
CSVData = CSVData & ",""" & rsData.Fields(K).Name & """"
Next K
CSVData = Mid(CSVData, 2) & vbNewLine
TxtStr.Write CSVData
End If
Do While rsData.EOF = False
CSVData = """" & rsData.GetString(adClipString, 1000, """,""", """" & vbNewLine & """", NULLStr)
CSVData = Left(CSVData, Len(CSVData) - Iif(rsData.EOF, 3, 2))
TxtStr.Write CSVData
Loop
TxtStr.Close
End Sub
答案 4 :(得分:0)
这是一种可爱的低技术方式: https://www.sqlbi.com/articles/linkback-tables-in-powerpivot-for-excel-2013/
我认为该过程在Excel 2016中有所不同。如果您拥有Excel 2016,则只需转到“数据”选项卡,依次转到“获取外部数据”,然后单击“现有连接”(并在“表”下查看)。
另一个重要的事情是单击“取消链接”(在“表工具-设计-外部表数据”下)。这会将其与源数据断开链接,因此它实际上仅是导出。
您可以将数据复制到另一个工作簿中。