FPSpreadsheet: AV on TWorkbook.WriteToFile() lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- JP-CASSOU · 2023-07-13 09:22 Hello, Using TWorkbook: When not use FWorkbook.AddCellFormat(), I obtains 'List index out of bounds' Else, I obtains 'Access violation' using TWorkbook.WriteToFile() ---------------------------------------------------------------------- wp · 2023-07-13 09:34 Sorry, this is not enough information. Post a SMALL (!) project demonstrating the issue. ---------------------------------------------------------------------- JP-CASSOU · 2023-07-13 11:13 If CS.SetBorders specified : -> Access Violation, else OK Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  CS: TsCellFormat;  // TsCellFormat est un record  BS: TsCellBorderStyles;begin        BS := DEFAULT_BORDERSTYLES;     CS.Name := AStyleName;    CS.ID   := FWorkbook.GetNumCellFormats();  CS.VertAlignment := TsVertAlignment.vaCenter;       CS.SetBackground(TsFillStyle.fsSolidFill, ACellColor, ACellColor);    CS.SetFont(0);    CS.SetNumberFormat(0);    CS.SetHorAlignment(TsHorAlignment.haDefault);    CS.SetVertAlignment(TsVertAlignment.vaDefault);    CS.SetTextRotation(TsTextRotation.trHorizontal);     // CS.SetBorders([]); // <-- AV in WriterToFile if specified     FWorkbook.AddCellFormat(CS);                           Additionnally, how to specify OOo Styles ? ---------------------------------------------------------------------- wp · 2023-07-13 13:28 Please post a compilable project. The project that I create from your snippet works correctly. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; uses  fpspreadsheet, fpstypes, fpsallformats;var  FWorkbook: TsWorkbook;  FWorksheet: TsWorksheet;  FCell: PCell;  CS: TsCellFormat;  // TsCellFormat est un record  BS: TsCellBorderStyles;  ACellColor: TsColor;  idx: Integer;begin  ACellColor := scRed;   FWorkbook := TsWorkbook.Create;  try    FWorksheet := FWorkbook.AddWorksheet('Page 1');     BS := DEFAULT_BORDERSTYLES; //  CS.Name := AStyleName;    CS.ID   := FWorkbook.GetNumCellFormats();  CS.VertAlignment := TsVertAlignment.vaCenter;    CS.SetBackground(TsFillStyle.fsSolidFill, ACellColor, ACellColor);    CS.SetFont(0);    CS.SetNumberFormat(0);    CS.SetHorAlignment(TsHorAlignment.haDefault);    CS.SetVertAlignment(TsVertAlignment.vaDefault);    CS.SetTextRotation(TsTextRotation.trHorizontal);    CS.SetBorders([]);     idx := FWorkbook.AddCellFormat(CS);     FCell := FWorksheet.WriteText(0, 0, 'Test');    FWorksheet.WriteCellFormat(FCell, FWorkbook.GetCellFormat(idx));     FWorkbook.WriteToFile('test.xlsx', true);   finally    FWorkbook.Free;  end;end.                             Quote from: JP-CASSOU on July 13, 2023, 01:13:19 pmAdditionnally, how to specify OOo Styles ?                              FPSpreadsheet does not support the "Styles" introduced by Excel and LibreOffice. Every cell must be formatted individually.