2017-11-11 191 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>