I found a bug in the spire.doc-library. I am using spire office version 2.5.10.
When adding a newline as first character and adding that to cell, i recieve the following error:
at System.String.Remove(Int32 startIndex)
at sprើ.ᜂ(ParagraphBase A_0)
at sprើ.ᜈ(ParagraphBase A_0)
at sprើ.ᜀ(ParagraphItemCollection A_0)
at sprើ.ᜀ(Paragraph A_0, Boolean A_1)
at sprើ.ᜀ(BodyRegion A_0, Boolean A_1)
at sprើ.ᜃ(TableCell A_0)
at sprើ.ᜀ(CellCollection A_0)
at sprើ.ᜀ(TableRow A_0, Boolean A_1, Boolean A_2)
at sprើ.ᜀ(RowCollection A_0)
at sprើ.ᜅ(Table A_0)
at sprើ.ᜀ(BodyRegion A_0, Boolean A_1)
at sprើ.ᜀ(BodyRegionCollection A_0, Boolean A_1)
at sprើ.ᜇ(Section A_0)
at sprើ.ᜢ()
at sprើ.ᜬ()
at sprើ.ᜀ(Stream A_0, Document A_1)
at sprើ.ᜀ(String A_0, Document A_1)
at Spire.Doc.Document.ᜈ(String A_0)
at Spire.Doc.Document.SaveToFile(String fileName, FileFormat fileFormat)
at SpireBug.Program.CreateDetailedDocument(String filename) in c:\users\jslots\documents\visual studio 2010\Projects\SpireBug\SpireBug\Program.cs:line 33
at SpireBug.Program.Main(String[] args) in c:\users\jslots\documents\visual studio 2010\Projects\SpireBug\SpireBug\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I removed all unnecessary code so this is the only code with which i can reproduce the problem.
- Code: Select all
class Program
{
static void Main(string[] args)
{
Spire.License.LicenseProvider.SetLicenseFileName("license.elic.xml");
CreateDetailedDocument(@"C:\temp\test.docx");
}
private static void CreateDetailedDocument(string filename)
{
Document d = new Document();
Section section1 = CreateSection(d);
Table table = section1.AddTable(false);
TableRow tr = table.AddRow(2);
string value = "\nvalue";
string key = "colname";
tr.Cells[0].AddParagraph().AppendText(key);
tr.Cells[1].AddParagraph().AppendText(value ?? " ");
d.SaveToFile(filename, FileFormat.Docx2010);
}
private static Section CreateSection(Document d)
{
if (d == null) return null;
Section section1 = d.AddSection();
section1.PageSetup.PageSize =PageSize.A4;
section1.PageSetup.Orientation = PageOrientation.Portrait;
return section1;
}
}
Can you try to reproduce this issue?
Thanks in advance,
Johan