J'essaie d'écrire un code pour générer une feuille de calcul Excel et je ne suis pas sûr de la différence entre CellValues.InlineString y CellValues.String pour insérer du texte dans les cellules.
Dois-je utiliser ceci ?
private void UpdateCellTextValue(Cell cell,string cellValue)
{
InlineString inlineString = new InlineString();
Text cellValueText = new Text { Text = cellValue };
inlineString.AppendChild(cellValueText);
cell.DataType = CellValues.InlineString;
cell.AppendChild(inlineString);
}
cette
private void UpdateCellTextValue(Cell cell, string cellValue)
{
cell.CellValue = new CellValue(cellValue);
cell.DataType = new EnumValue<CellValues>(CellValues.String);
}
ou simplement ceci (InsertSharedStringItem renvoie l'Id de l'élément de chaîne partagée nouvellement inséré)
private void SetCellSharedTextValue(Cell cell,string cellValue)
{
int stringId = InsertSharedStringItem(cellValue);
cell.CellValue = new CellValue(stringId.ToString());
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
}