How to add borders in Export to Excel?

chandrurecchandrurec Member Posts: 560
Hi all,

I am trying to add the boreders for the datas exported to excel.

So I try to make use of the function BorderAround function available in Excel Buffer table.

But When I try to run the excel , it is giving me the error

"The Automation Variable is not instantiated".

The coding I have given for Body section is as follows.


//ExcelBuf.CreateRangeName('Range',1,1);
ExcelBuf.StartRange;
ExcelBuf.AddColumn('Depot Code',FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn(gItemName[1],FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn(gItemName[2],FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn(gItemName[3],FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn('Total',FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn(gItemName[4],FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn(gItemName[5],FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn(gItemName[6],FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn('Total',FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn(gItemName[7],FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn(gItemName[8],FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn(gItemName[9],FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.AddColumn('Total',FALSE,'',TRUE,FALSE,TRUE,'');
ExcelBuf.EndRange;



ExcelBuf.CreateRangeName('Range',1,1);
ExcelBuf.CreateRange('Range');
ExcelBuf.BorderAround('Range');

I think the sequnce I am calling the function is wrong.

If anyone know the correct sequence to make the BorderAround function to work,Kindly correct the code above or tell me the correct sequence.

Thanks in advance.

Regards,
Chandru.

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • chandrurecchandrurec Member Posts: 560
    Hi Luc Van Dyck ,

    I have searched in the link which you have sent. It contains queries for adding borders through automation and not uisng the BorderAround function of Excel Buffer.

    Kindly let me know how to add borders using the BorderAround function in ExcelBuffer.

    Thanks in advance.

    Regards,
    Chandru.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I'm sorry to hear that my answer is not 100% exactly what you are looking for. But the link I mentioned, gives you the info to modify the Excel Buffer table, to get the same result. I can do this job for you, but then I have to send you an invoice for my work hours.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • chandrurecchandrurec Member Posts: 560
    Hi Luc,

    By modifying the LineStyle, I go the output.

    Thanks a lot.

    Regards,
    Chandru.
  • engsiong75engsiong75 Member Posts: 143
    Hi Folks

    If you want to use the Excelbuf.BorderAround, this is an sample of the code.

    ExcelBuf.CreateRangeName(ExcelBuf.GetExcelReference(8),1,5);
    LInt_RowCounter := 5;
    LInt_ColCounter := 1;

    REPEAT
    REPEAT
    ExcelBuf.SetCurrent(LInt_RowCounter,LInt_ColCounter);
    ExcelBuf.StartRange;
    ExcelBuf.SetCurrent(LInt_RowCounter,LInt_ColCounter);
    ExcelBuf.EndRange;
    ExcelBuf.CreateRange(ExcelBuf.GetExcelReference(8));
    ExcelBuf.BorderAround(ExcelBuf.GetExcelReference(8));
    LInt_ColCounter := LInt_ColCounter + 1;
    UNTIL LInt_ColCounter > (GInt_ColCounter + 1);
    LInt_ColCounter := 1;
    LInt_RowCounter := LInt_RowCounter + 1;
    UNTIL LInt_RowCounter > (GInt_RowCounter + 1);

    Tan Eng Siong
  • SavatageSavatage Member Posts: 7,142
    I use BorderStyle here:
    IF Row < 10
    THEN TempExcelBuffer."Border Style" := 0
    ELSE TempExcelBuffer."Border Style" := 1;
    http://www.youtube.com/watch?v=WQ63cFCPBOQ

    From:
    viewtopic.php?f=23&t=45618

    just to add some more info.
  • Prajeesh_NairPrajeesh_Nair Member Posts: 70
    Hi engsiong75 :| ,

    I am getting an error like The automation Variable has not initiated ](*,) . Please can u guide me through it? :?: Can i use the same code to create boarder for all variable which i am inserting into excel :-k , ie all entries in excel is inside a box...
Sign In or Register to comment.