यह एक दो भाग सवाल यह है कि जब मैं दस्तावेज़ को खोलने का प्रयास मैं वहाँ सामग्री के साथ एक समस्या यह है कि कोई त्रुटि मिलती है:
1) मैं एक OpenXML TableCell
foregroun के अग्रभाग को कैसे संशोधित कर सकते हैं ओपनएक्सएमएल TableCell
का डी Run
के गुणों द्वारा परिभाषित किया गया है, जिसे RunProperties
कहा जाता है। रन में रंग जोड़ने के लिए, आपको Val
संपत्ति का उपयोग करके Color
ऑब्जेक्ट जोड़ना होगा।
// Create the RunProperties object for your run
DocumentFormat.OpenXml.Wordprocessing.RunProperties rp =
new DocumentFormat.OpenXml.Wordprocessing.RunProperties();
// Add the Color object for your run into the RunProperties
rp.Append(DocumentFormat.OpenXml.Wordprocessing.Color() { Val = "ABCDEF" });
// Create the Run object
DocumentFormat.OpenXml.WordProcessing.Run run =
new DocumentFormat.OpenXml.WordProcessing.Run();
// Assign your RunProperties to your Run
run.RunProperties = rp;
// Add your text to your Run
run.Append(new Text("My Text"));
reference question देखें।
2) मैं एक OpenXML TableCell
TableCell
पृष्ठभूमि की पृष्ठभूमि कैसे संशोधित कर सकते हैं TableCellProperties
, ऊपर Run
, जो RunProperties
का उपयोग करता है के लिए इसी तरह का उपयोग कर संशोधित किया जा सकता। हालांकि, आप अपने TableCellProperties
पर Shading
ऑब्जेक्ट लागू करते हैं।
// Create the TableCell object
DocumentFormat.OpenXml.Wordprocessing.TableCell tc =
new DocumentFormat.OpenXml.Wordprocessing.TableCell();
// Create the TableCellProperties object
TableCellProperties tcp = new TableCellProperties(
new TableCellWidth { Type = TableWidthUnitValues.Auto, }
);
// Create the Shading object
DocumentFormat.OpenXml.Wordprocessing.Shading shading =
new DocumentFormat.OpenXml.Wordprocessing.Shading() {
Color = "auto",
Fill = "ABCDEF",
Val = ShadingPatternValues.Clear
};
// Add the Shading object to the TableCellProperties object
tcp.Append(shading);
// Add the TableCellProperties object to the TableCell object
tc.Append(tcp);
// also need to ensure you include the text, otherwise it causes an error (it did for me!)
tc.Append(new Paragraph(new Run(new Text(cellText))));
reference question देखें।
स्रोत
2013-07-16 13:29:28
क्या आप हमें पूर्ण त्रुटि संदेश और त्रुटि जो फेंकने वाली रेखा को बता सकते हैं। –
मैंने त्रुटि की एक छवि शामिल की है। वहां वास्तव में बहुत अधिक जानकारी नहीं है। क्या मैं कहीं और पा सकता हूं? – DaveDev
आपकी फ़ाइल दूषित हो सकती है। मैन्युअल रूप से एक ही फ़ाइल खोलने का प्रयास करें। यदि यह खुलता है तो कोड में कुछ गलती हो सकती है। –