Options

How to export excel in left align always?

chandrurecchandrurec Member Posts: 560
edited 2013-08-28 in NAV Three Tier
Hi all,

I want to export the data to excel using excel buffer concept. By stand , text will be left aligned and numeric will be right aligned. But I want always to follow the left alignment.

so I read one forum in mibuso and put the following code in excel buffer table.

XlWrkSht.Range(xlColID + xlRowID).HorizontalAlignment := HorzAlign;


but after I put this code , its still works the std way.

if anyone knows how to achieve the scenario, kindly let me know.

Thanks in advance,

Regards,
chandru.

Comments

  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    You can also add ' before decimal value to make it text which will automatically assign to left.
  • Options
    chandrurecchandrurec Member Posts: 560
    Hi Mohana,

    I tried to assign the decimal to text using format but still I found that the alignment is not left aligned.

    Thanks & Regards,
    chandru.
  • Options
    davmac1davmac1 Member Posts: 1,283
    Excel still interprets it as numeric.
    Add the ' before the number as recommended and it will be treated as text.


    Value:='''' + FORMAT(Number);
  • Options
    geordiegeordie Member Posts: 655
    Setting the alignment, did you use these values?
    XlWrkSht.Range(xlColID + xlRowID).HorizontalAlignment :=  -4108; //Center
    XlWrkSht.Range(xlColID + xlRowID).HorizontalAlignment :=  -4131; //Left
    XlWrkSht.Range(xlColID + xlRowID).HorizontalAlignment :=  -4152; //Right
    
  • Options
    MikeConnor13MikeConnor13 Member Posts: 3
    Have you tried using CStr to convert decimal values to string?

    i.e.
    aDecimalVariable = Cstr(aDecimalVariable)

    should treat the new value of 'aDecimalVariable' as a string.
Sign In or Register to comment.