[WriteBlank function - C++ Flexcel VCL]

Hi everbody,


I'm searching for a flexcel function that write blank in a cell like the function  "TNoParam()".
Is there any available function similar to the function TNoParam().
I m doing a migration project using microsoft xls library.
My function is below:

void __fastcall TExcelExportForm::WriteBlank(int Column, int Row, int ColEnd, int RowEnd)
  {
  try
    {
    if (!XLWorkSheet)
      {
      return ;
      }

    Variant Cell1 = WideString(AnsiString().sprintf("%c%d",'A'+ (Column - 1), Row)) ;
    Variant Cell2 = WideString(AnsiString().sprintf("%c%d",'A'+ (ColEnd - 1), RowEnd)) ;

    XLWorkSheet->Range[Cell1][Cell2]->set_Value(TNoParam()) ;
    }

  catch(...)
    {
    }
  }
Is there any function as the function Writeblank() or I have to the function SetCellValue and built the same logique.

I thank you for your help.

Best regards,

Hi,

Technically the equivalent of TNoParam would be TCellValue::Empty.
So to clear a range you could call:

  xls->SetCellValue(row, col, TCellValue::Empty());


But for this particular function (clearing a block of cells), you can use DeleteRange:

  xls->DeleteRange(TXlsCellRange::Create(row1, col1, row2, col2), TFlxInsertMode::NoneDown);

Thanks Adrian,
It works super. However, I'm using a xls template file and all cell has a border, so when I use the function that you tell me it deletes the cell content and also the border line of the cell. So is there any precision to keep the border line of the cell when I delete its value.

Best regards,

We have you covered :)




  xls->DeleteRange(xls->ActiveSheet, xls->ActiveSheet, TXlsCellRange::Create(1, 1, 2, 5), TFlxInsertMode::NoneDown, false);


The last parameter means that it won't remove the cell formats, including borders.

Super!

Thanks for your support . 
It works.

Best regards,