2011-06-24 7 views
15

मैं एक्सेल स्प्रेडशीट उत्पन्न करने के लिए कुछ कोड लिखने की कोशिश कर रहा हूं और मुझे यकीन नहीं है कि सेलवैल्यूज़ के अंदर क्या अंतर है। इनलाइनस्ट्रिंग और सेलवैल्यूज़। स्ट्रिंग कोशिकाओं पर टेक्स्ट डालने के लिए।OpenValues.InlineString और CellValues.Stx के बीच क्या अंतर है OpenXML में स्ट्रिंग?

मैं इस का उपयोग करेगा:

private void UpdateCellTextValue(Cell cell,string cellValue) 
{ 
    InlineString inlineString = new InlineString(); 
    Text cellValueText = new Text { Text = cellValue }; 
    inlineString.AppendChild(cellValueText); 

    cell.DataType = CellValues.InlineString; 
    cell.AppendChild(inlineString); 
} 

इस

private void UpdateCellTextValue(Cell cell, string cellValue) 
{ 
    cell.CellValue = new CellValue(cellValue); 
    cell.DataType = new EnumValue<CellValues>(CellValues.String); 
} 

या सिर्फ इस (InsertSharedStringItem रिटर्न नव डाला साझा स्ट्रिंग मद की ईद)

private void SetCellSharedTextValue(Cell cell,string cellValue) 
{   
    int stringId = InsertSharedStringItem(cellValue); 
    cell.CellValue = new CellValue(stringId.ToString()); 
    cell.DataType = new EnumValue<CellValues>(CellValues.SharedString); 
} 

उत्तर

13

के अनुसार 18.18.11 ST_CellType पर प्रलेखन:

स्ट्र (स्ट्रिंग) सेल जिसमें सूत्र स्ट्रिंग है।

आप केवल सेलवैल्यूज़ का उपयोग करना चाहते हैं। जब आप सेल में सूत्र बना रहे हैं तो स्ट्रिंग करें। यहाँ कैसे एक्सएमएल दिखना चाहिए है: यदि आप SharedStringTable में स्ट्रिंग स्टोर करने के लिए नहीं करना चाहती

<x:c r="C6" s="1" vm="15" t="str"> 
    <x:f>CUBEVALUE("xlextdat9 Adventure Works",C$5,$A6)</x:f> 
    <x:v>2838512.355</x:v> 
</x:c> 

CellValues.InlineString केवल इस्तेमाल किया जाना चाहिए। फिर inlineString के रूप में चिह्नित कुछ भी समृद्ध टेक्स्ट के रूप में माना जाएगा। हालांकि ध्यान दें कि जब आप CellValues.InlineString का उपयोग करने वाले अपने पाठ एक पाठ तत्व द्वारा और surounded किया जाना चाहिए <is> टैग:

<x:c r="B2" t="inlineStr"> 
    <is><t>test string</t></is> 
</c> 
+0

कृपया जहां प्रलेखन आप से उद्धृत की कड़ी है? –

+1

मैंने ओपन एक्सएमएल स्पेक के लिए पीडीएफ डाउनलोड करने के लिंक के साथ उत्तर अपडेट किया। उदाहरणों के लिए आप यहां खोज सकते हैं या इस माइक्रोसॉफ्ट लिंक का संदर्भ सकते हैं http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.cell%28v=office.14%29.aspx – amurra

संबंधित मुद्दे