TAdvSpreadGrid Header with CSV

I am trying to import various file types into a TAdvSpreadGrid. Importing XLS and XLSX files works great using the TADVGridExcelImport component. But when trying to import CSV files I cannot get the header row to import into the fixed rows, no matter what I try. It either does not show up at all, or it shows up in the data rows. I get this when using a direct LoadFromCSV(FileName) or using the TAdvGridimportDialog. I saw references to SaveFixedCells so I tried that, too, but it didn't help.

I need to allow importing a lot of different files, so I can't just assign the headers manually without parsing out the header row ... something I should not have to do.

If you set grid.SaveFixedCells = true, using LoadFromCSV() should load data from the first (fixed) cells into the grid. I retested this and this works as expected here. If a problem persists with the latest version of TAdvStringGrid, please provide details to reproduce.

It works great with a TADVStringGrid, if that were what I wanted to use. I am trying to use a TAdvSpreadGrid.

Drop a SpreadGrid on a form and name it sGrid. Drop a stringGrid on a form and name it StringGrid. Create a simple CSV file with a header named "HeaderTest.csv". Paste the code below into the buttonclick event. Very straightforward example. Tell me how well it works.


  sgrid.FixedRows := 1;
  FileName := 'HeaderTest.csv';
  sgrid.FilterEdit.Enabled := true;
  sGrid.SaveFixedCells := true;
  sGrid.LoadFromCSV(FileName);
  sGrid.Options := sGrid.Options + [goColSizing, goColMoving];
  sGrid.AutoSizeCells(true,4,8);
  sGrid.Visible := True;

//  StringGrid

  StringGrid.FixedRows := 1;
  StringGrid.FilterEdit.Enabled := true;
  StringGrid.SaveFixedCells := true;
  StringGrid.LoadFromCSV(FileName);
  StringGrid.Options := sGrid.Options + [goColSizing, goColMoving];
  StringGrid.AutoSizeCells(true,4,8);
  StringGrid.Visible := True;

Also, it looks like even if the headers import properly using a TADVGridExcelImport component, they get blown out when doing InsertCols. The header names revert to A, B, C etc.

Did you set AdvSpreadGrid.AutoHeaders = false?

Thank you, that was what I didn't understand. That fixed both problems.