troubleshooting Question

Problem to event

Avatar of Peter Chan
Peter ChanFlag for Hong Kong asked on
C#Programming Languages-Other.NET ProgrammingXMLSystem Programming
3 Comments2 Solutions311 ViewsLast Modified:
How to correct

        public static void InsertText(string docName, string text)
            // Open the document for editing.
            Using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Open(docName, true))
                // Get the SharedStringTablePart. If it does not exist, create a new one.
                SharedStringTablePart shareStringPart;
                if (spreadSheet.WorkbookPart.GetPartsOfType<SharedStringTablePart>().Count() > 0)
                    shareStringPart = spreadSheet.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First();
                    shareStringPart = spreadSheet.WorkbookPart.AddNewPart<SharedStringTablePart>();

                // Insert the text into the SharedStringTablePart.
                int index = InsertSharedStringItem(text, shareStringPart);

                // Insert a new worksheet.
                WorksheetPart worksheetPart = InsertWorksheet(spreadSheet.WorkbookPart);

                // Insert cell A1 into the new worksheet.
                Cell cell = InsertCellInWorksheet("A", 1, worksheetPart);

                // Set the value of cell A1.
                cell.CellValue = new CellValue(index.ToString());
                cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);

                // Save the new worksheet.
due to these errors?
Error	1	) expected	C:\App\WindowsFormsApplication9_4_0_1\WindowsFormsApplication2\Form1.cs	451	40	WindowsFormsApplication2
Error	2	Invalid expression term ')'	C:\App\WindowsFormsApplication9_4_0_1\WindowsFormsApplication2\Form1.cs	451	93	WindowsFormsApplication2
Error	3	; expected	C:\App\WindowsFormsApplication9_4_0_1\WindowsFormsApplication2\Form1.cs	451	93	WindowsFormsApplication2
Error	4	; expected	C:\App\WindowsFormsApplication9_4_0_1\WindowsFormsApplication2\Form1.cs	451	94	WindowsFormsApplication2
Join our community to see this answer!
Unlock 2 Answers and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros