2017-11-11 195 views
0

如果用戶自定義了Windows 10中的數字格式,特別是在選定US區域的計算機上,Microsoft Access 2016(內部版本16.0.8201.2200)中的VBA TransferSpreadsheet method無法正常工作,則TransferSpreadsheet會生成無效的XLSX文件,如果換成「小數點符號」和「數字分組符號」進行格式化一樣習慣在德國:如果用戶自定義小數點分隔符

enter image description here

當我使用TransferSpreadsheet保存查詢,當我後來試圖在Excel中打開工作簿它說:

我們在'...'的某些內容中發現了一些問題。你想讓我們儘可能多地恢復嗎?

enter image description here

當我這樣做,我得到以下警告:

Excel能通過修復或刪除無法讀取內容打開文件。

enter image description here

當我看的XLSX內容的內容,我並不感到驚訝它是有問題的,因爲沒有很好地形成內部的XML。因爲我已經在Windows中將小數點分隔符替換爲「,」,所以它使用逗號而不是小數位來創建XML中的數字。但XML標準規定,無論您的地區偏好如何,XML中的數字都應該使用「。」。作爲小數點符號。

<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"> 
    <dimension ref="A1:K20"/> 
    <sheetViews>...</sheetViews> 
    <sheetFormatPr defaultRowHeight="15"/> 
    <sheetData> 
    <row outlineLevel="0" r="1">...</row> 
    <row outlineLevel="0" r="2"> 
     ... 
     <c r="D2" s="0"> 
     <v>2,9328903531E+16</v> 
     </c> 
     <c r="E2" s="0"> 
     <v>5,404939826E+16</v> 
     </c> 
     <c r="F2" s="0"> 
     <v>2,3923963705E+16</v> 
     </c> 
     ... 
    </row> 
    ... 
    </sheetData> 
    <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> 
</worksheet> 

雖然「」可能是在UI小數點符號所需的格式,所述XLSX內部格式必須符合XML標準,「」十進制符號。

我該如何解決這個問題?

+0

此錯誤不是在建16.0.8625.2121重複性。該bug的範圍可能真的很窄。 –

回答

1

底線,爲TransferSpreadsheet方法才能正常工作,如果你想更換號碼的格式,不要使用「自定義格式」設置:

enter image description here

而應該重置這些值回到它們的默認值,然後選擇在前面的對話框中適當的區域,一個數字格式化爲你喜歡:

enter image description here

就吃g選擇一個根據需要格式化的區域,從而避免出現TransferSpreadsheet錯誤。當你這樣做時,將電子表格在Excel中正確顯示:

enter image description here

但XLSX將格式正確的,太:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"> 
    <dimension ref="D3:F3"/> 
    <sheetViews> 
    <sheetView tabSelected="1" workbookViewId="0"> 
     <selection activeCell="F12" sqref="F12"/> 
    </sheetView> 
    </sheetViews> 
    <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/> 
    <cols> 
    <col min="4" max="6" width="26.85546875" style="1" bestFit="1" customWidth="1"/> 
    </cols> 
    <sheetData> 
    <row r="3" spans="4:6" x14ac:dyDescent="0.25"> 
     <c r="D3" s="1"> 
     <v>2.9328903531E+16</v> 
     </c> 
     <c r="E3" s="1"> 
     <v>5.40493826E+16</v> 
     </c> 
     <c r="F3" s="1"> 
     <v>2.3923963705E+16</v> 
     </c> 
    </row> 
    </sheetData> 
    <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> 
</worksheet>