Excel 2010中的共享字符串 [英] Shared Strings in Excel 2010

查看:178
本文介绍了Excel 2010中的共享字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我理解 MS Excel 中的共享字符串吗?我尝试使用一些博客来了解,但无法获得完整的想法.每个人都在解释如何使用Open XML访问共享字符串以及共享字符串的存储位置(如sharedStrings.xml).使用API​​进行访问是可以的.但是

  1. 如何在 Excel 中创建共享字符串. (不使用API​​在 Excel 2010 中手动创建)
  2. 共享字符串的确切需求是什么?
  3. 在哪种情况下我可以使用共享字符串?

我尝试关注.

http://msdn.microsoft.com/en-us/library /gg278314.aspx

解决方案

共享字符串基本上是一种节省空间的机制.至于您的问题:

A1 .您无法使用Excel用户界面手动创建共享字符串.这是因为默认情况下,Excel始终将任何文本存储为共享字符串.

A2 .如前所述,这是一种节省空间的机制. Excel 2007/2010/2013使用Open XML格式,该格式基本上是一堆压缩在一起的XML文件.也可能是为了便于参考.您只需要引用索引,就像引用字符串数组的索引一样. (但是XML本质上很冗长,所以我怀疑它是为了节省空间.)

假设您在工作表"FirstSheet"的单元格A1中有文本这是一个很长的字符串".假设您在工作表"SecondSheet"的单元格B7中也具有相同的文本. Excel将这是一个很长的文本"存储在共享字符串表中,作为一个条目,例如索引5.在"FirstSheet"单元格A1中,Open XML SDK类Cell将仅包含"5"作为CellValue.在"SecondSheet"单元格B7中,SDK类单元格还将包含"5".

基本上,CellValue仅保存共享字符串表的索引.这是节省空间的方式.假设文本是在工作表内以及在不同的工作表内都是重复的.

A3 .如果您了解如何使共享字符串起作用,请选择共享字符串.如果没有,只需在Cell类中为CellValue设置实际文本(Cell.DataType为CellValues.String而不是CellValues.SharedString).

Can someone help me in understanding the Shared Strings in MS Excel? I tried to understand using some blogs but could not get complete idea. Everyone is explaining how to access Shared String using Open XML and where the Shared Strings stored (as sharedStrings.xml). Accessing using API is fine. But,

  1. How to create Shared Strings in Excel. (Creating manually in Excel 2010, not using API)
  2. What is the exact need of Shared Strings?
  3. In which cases i can go for Shared Strings?

I tried following.

http://www.sadev.co.za/content/reading-and-writing-excel-2007-or-excel-2010-c-part-iii-shared-strings

http://msdn.microsoft.com/en-us/library/gg278314.aspx

解决方案

Shared strings is basically a space saving mechanism. As for your questions:

A1. You can't manually create shared strings using the Excel user interface. That's because Excel by default always store any text as a shared string.

A2. As mentioned it's a space saving mechanism. Excel 2007/2010/2013 uses the Open XML format, which is basically a bunch of XML files zipped together. It might also be for ease of referencing. You just have to refer to an index, just like you refer to an index of an array of strings. (But XML is inherently verbose, so I suspect it's for space saving purposes).

Let's say you have the text "This is a very long string" in cell A1 of sheet "FirstSheet". Let's say you also have the same text in cell B7 of sheet "SecondSheet". Excel stores "This is a very long text" in the shared strings table as one entry, say index 5. In "FirstSheet" cell A1, the Open XML SDK class Cell will contain just "5" as the CellValue. In "SecondSheet" cell B7, the SDK class Cell will also contain "5".

Basically, the CellValue only holds the index to the shared string table. This is how you save space. The assumption is that text is duplicated within the worksheet as well as across different worksheets.

A3. Go for shared strings if you understand how to make it work. If not, just set the actual text in the Cell class for CellValue (Cell.DataType as CellValues.String instead of CellValues.SharedString).

这篇关于Excel 2010中的共享字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆