Peter Chan
asked on
Problem to event
Hi,
How to correct
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();
}
else
{
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.
worksheetPart.Worksheet.Save();
}
}
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I encounter this
Open in new window
due to last line belowOpen in new window
while the codes are fromhttps://msdn.microsoft.com/en-us/library/office/cc861607.aspx?f=255&MSPPError=-2147217396