问题
I use closedXml and I want to concatenate cells which located in one row.
In column E/F/G is what I have. And in column J is that I want to see:
In addition, I want to save bold/italic format
Can anyone help me?
回答1:
A little more complicated than I expected it to be but still relative straightforward.
Copy each RichText
part from the three source cells to the target cell:
XLWorkbook wb = new XLWorkbook(@"c:\temp.xlsx");
IXLWorksheet worksheet = wb.Worksheet(1);
foreach (IXLRow row in worksheet.RowsUsed())
{
row.Cell("J").RichText.ClearText();
foreach (var rt in row.Cell("E").RichText)
{
row.Cell("J").RichText.AddText(rt.Text).CopyFont(rt);
}
row.Cell("J").RichText.AddText(" ");
foreach (var rt in row.Cell("F").RichText)
{
row.Cell("J").RichText.AddText(rt.Text).CopyFont(rt);
}
row.Cell("J").RichText.AddText(" ");
foreach (var rt in row.Cell("G").RichText)
{
row.Cell("J").RichText.AddText(rt.Text).CopyFont(rt);
}
}
wb.Save();
来源:https://stackoverflow.com/questions/56885548/how-can-i-concatenate-several-cells-with-text