没有列名的动态总和公式

时间:2015-12-23 06:59:01

标签: excel excel-formula

我从外部系统生成Excel xml文件。现在我面临着摘要单元格的问题。当然我可以只在其他系统中对数据进行求和,但我真的希望得到文件的真实和公式。

有没有办法在不知道列名的情况下对单元格求和?有没有,例如像这样的东西(将第1行到第10行的当前列数据相加):

=SUM(THISCOLUMN1:THISCOLUMN10)

这会是一个好方法还是你的想法?在我的情况下,每次生成Excel文件时列数都会有所不同。

如果不可能,那么我想我必须在我的程序中将当前列号索引转换为Excel列名语法。

简化示例:http://pastebin.com/YMxggt7v

2 个答案:

答案 0 :(得分:0)

我在Axel Richter的帮助下找到了合适的解决方案:

Cell ss:Formula="=SUM(R[-2]C[0]:R[-1]C[0])">
  <Data ss:Type="Number"></Data>
</Cell>

然后我只需要根据行数I改变R [-2]。

答案 1 :(得分:0)

以下XML适用于Excel 2007:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <Worksheet ss:Name="Tabelle1">
  <Table>
   <Row ss:Index="11">
    <Cell ss:Formula="=SUM(R1C:R10C)"></Cell>
    <Cell ss:Formula="=SUM(R1C:R10C)"></Cell>
    <Cell ss:Formula="=SUM(R1C:R10C)"></Cell>
    <Cell ss:Formula="=SUM(R1C:R10C)"></Cell>
   </Row>
  </Table>
 </Worksheet>
</Workbook>

将其保存为* .xml并使用File-Open使用Excel打开它。或者将其保存为* .xls并双击打开它。

有关XML Spreadsheet 2003的参考,请参阅https://msdn.microsoft.com/en-us/library/aa140066%28office.10%29.aspx

相关问题