Alignment of Columns in Excel when sent as an attachement

Hi,
I am using below code to send the output of ALV via email as an attachment.
data : lv_variant type sy-slset value 'VARIANT',
         lt_list   type table of abaplist,
         lt_0167_body type standard table of soli,
         ls_body_raw type soli,
         lt_txt type soli_tab.
data:   ls_string type text2048,
          lt_objbin type soli_tab,"Attachment of EMail
          lt_objbinx type solix_tab,"Attachment of EMail
          lv_dlist type so_obj_nam,
          lv_bdate type char10,
          lv_edate type char10,
          lv_title type char40.
submit ztest using selection-set lv_variant exporting list to memory and return.
call function 'LIST_FROM_MEMORY'
  tables
    listobject = lt_list "Binary data
  exceptions
    not_found  = 1.
call function 'LIST_TO_TXT'
  tables
    listtxt            = lt_txt
    listobject         = lt_list
  exceptions
    empty_list         = 1
    list_index_invalid = 2
    others             = 3.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
move 'test' to ls_body_raw.
append ls_body_raw to lt_0167_body.
lt_0167_body[] = lt_0167_body[].
data :
    l_hex type solix,
    conv type ref to cl_abap_conv_out_ce,
    l_buffer type xstring,
    l_hexa(510) type x.
  loop at lt_txt   into ls_string.
    conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'B').
    call method conv->write( data = ls_string ).
    l_buffer = conv->get_buffer( ).
    move l_buffer to l_hexa.
    move l_hexa to l_hex-line.
    append l_hex to lt_objbinx.
  endloop.
call method ztest=>send_mail
  exporting
    it_errormessages     = lt_0167_body
    iv_type              = 'RAW'
    iv_dist_list         = 'DLIST' "distribution list
    iv_subject           =  'test'
    lv_attachment_type   = 'XLS'
    lv_attachment        = lt_objbinx
    lv_attachment_name   = 'Test'
  exceptions
    bcs_fault            = 1
    tvarv_not_maintained = 2
    others               = 3
here my custom method send_mail is working properly it is sending whatever is coming in lt_objbinx as  excel, only problem in the excel columns and column values are not aligned properly.
please suggest how can i align columns inside excel using abap code, send mail is actaully using cl_bcs and related classes for sending e-mail.
Thanks,
kranthi.

Hi change the below sample as per your requirement.
<unreadable code removed by moderator>
Regards
chitra
Moderator message: please post only relevant code parts, your posts must contain less than 5000 characters to preserve readable formatting.
Edited by: Thomas Zloch on Nov 15, 2011 1:03 PM

Similar Messages

  • Spool Is getting truncated when sent as email attachment

    Hi All,
    We are sending the spool lists for overnight jobs as emails (outlook) to certain users. The problem we are facing is that when the spool is big then not all the pages are getting transferred in the attachment. The list gets truncated.
    Has anyone faced a similar problem and if there is a way around this. Maybe there is some parameter setting in SAP which has to be adjusted.
    Pl advice.
    Thanks

    Hi
    I faced the same problem because in standard SAP dimensions of attachement is hard coded.
    Regards
    Aditya

  • Specifying the order of column in Excel file

    How to specify the order of the columns in excel when data is exported from a table to excel.For eg. I have 2 columns in a table i.e. Base Location and Employee Number.When I export this data to the excel file the columns are displayed according to the alphabetical order i.e. Base Location first and then Employee Number. Whereas I want Employee Number column to be displayed first and then the Base Location column.
    Can anyone help me on this?

    Hi Sowmya,
    when you refer to my Excel Export tutorial on SDN: <a href="https://wiki.sdn.sap.com/wiki/x/0mQ">Exporting Table Data Using On-Demand Streams - SAP NetWeaver 7.0</a>:
    use <b>LinkedHashMap</b> instead of <i>HashMap</i>:
      private Map getProductColumnInfos() {
        Map columnInfosMap = new LinkedHashMap();
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.QUANTITY, "Quantity");
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.ARTICLE, "Article");
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.COLOR, "Color");
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.PRICE, "Price in EURO");
        columnInfosMap.put(
          IPrivateTableCompBasketView.IProductsElement.TOTAL__PER__ARTICLE,
          "Total Per Article In Euro");
        return columnInfosMap;
    This keeps the order of key-displaytext-pairs passed by the client (table component) to the service (excel export component) stable.
    Regards, Bertram

  • How do i label columns in excel

    I need to know what code do i use in labview to label the columns in excel when the data is opened up in excel. Thank You
    Solved!
    Go to Solution.
    Attachments:
    Wii Balance Board-16.vi ‏1358 KB

    This is what it would look like:
    Ignore the fact that I compressed the code in the loop. The important part is that you write the first row once before the loop and the rest of the data inside the loop (with the append input as T).
    In general, this is very important to understand on your own if you expect to do anything in LV. I would strongly suggest you follow those tutorials and try learning from other places as well.
    Try to take over the world!

  • Make few columns of Excel file read only when downloaded

    Hi Experts,
    Is there any way we can set few of the columns in excel sheet as read only when downloaded from SAP.
    We have requirement where a program will generate a report and download it into an excel file on desktop.  When the file is downloaded, two of its columns should be non editable.
    I know complete sheet of excel can be protected using OLE, can we protect few columns also using OLE?
    any idea how can it be done?

    Hi Swapnil,
    check this
    Re: OLE EXCEL : how to block cells ?
    hope it is useful to you.
    Thanks

  • Why do attachment files in excel disapear in apple mail when sent from a PC

    I am trying to get excel files & they dissapear when sent from a PC network

    William (and cpiatek if you would like), you should read these:
    http://www.mywot.com/en/scorecard/winmaildat.com
    Winmaildat.com's privacy note:
    Privacy note
    Using this service means that your files are transmitted over the internet and saved on a foreign system for a short time. If your attachment contains unencrypted, sensitive data it is not a good idea to use this service.
    Your extracted files are saved on this system for some time so you can retrieve them. They are stored in a reasonably safe way so they names can't be guessed and will be deleted on your request or automatically after some time.
    We do not intend to look at your files and try our best to protect your files from other doing that.
    We use third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more informations, click here.
    http://www.siteadvisor.com/sites/winmaildat.com
    https://safeweb.norton.com/report/show?url=winmaildat.com
    http://siteinspector.comodo.com/public/reports/13659662

  • Agents failing when sent as attachments (pdf or excel) in OBIEE 11g

    Hello,
    We have issue agents failing with following error when set up with attachment (pdf or excel only) either as Dashboard or Report. If the same agent is run as inline then the agent is working fine. OBIEE version is 11.1.1.6.0 unclustered.
    [nQSError: 77006] Oracle BI Presentation Server Error: A fatal error occurred while processing the request. The server responded with: A fatal error occurred while processing the request. The server responded with: java.io.IOException: The system cannot find the path specified.
    Error Codes: AGEGTYVF
    Location: saw.rpc.mis.read, saw.subsystem.portal.pdf, saw.delivers.rpc.getDeviceContent, saw.rpc.server.responder, saw.rpc.server, saw.rpc.server.handleConnection, saw.rpc.server.dispatch, saw.threadpool.socketrpcserver, saw.threads
    We tried logging in as user/Administrator and running the report from catalog without any error. Also strangely this is evident in only a specific environment. Not sure what is causing the issue.
    Please advise.
    Thanks

    What is the size of the attachments of reports you are trying to send thru Agents .? either PDF or EXCEL ?
    What does you JavaHost log .?
    I think this is a same Bug 14680611 : ERROR CODES: AGEGTYVF RUNNING AGENTS WITH LARGE REPORT AS EXCEL ATTACHMENT
    If your are not able to download even smaller attachments/reports then, I would raise an SR with Oracle.
    Let us know. Hope this Helps.!
    Thanks,
    SVS

  • Error while opening Excel file sent through attachment in email in sap

    Hi All,
    I have implemented sending email with excel attachment in SAP.
    Email is sent successfully with attachment but when i tried to open it i get first error dialog like " file is not in recognizable format" but after that if i click ok then file gets opened correctly.
    Can you please sort this out.
    Thanks in advance.
    regards
    Ashutosh

    Go to the following link you will get solutions:
    ABAP BASIC

  • Dynamic columns with Excel Source?

    I have Excel file number 1 with columns A ja B.
    I have database table with columns A,B,C,D,E,F,G,H etc. (there are 100 columns)
    I know how to import normally data with Excel Source and OLE DB Destination with Excel file 1.
    Now I have new need.
    I should be able to import dynamically Excel files with any combination of columns.
    It should be automatic import with For Each Container.
    When new files like below is imported, I should not be make any changes to SSIS.
    Excel 2) Columns A, G, X (so column A data must be added to column A in database etc)
    Excel 3) Columns B, C, G, Y (so column B data must be added to column B in database etc)
    Excel 4) Columns D, X
    IS THIS POSSIBLE WITH SSIS? HOW?
    CUSTOM CODE IS NEEDED? ANY POINTERS TO SOLUTION?
    Kenny_I

    How you are going to deal with the rows here?
    For example, 
    Excel 2) Columns A, G, X (so column A data must be added to column A in database etc)
    when Excel 3 files are processing are you going to update the record that you added in Excel
    2.
    Excel 3) Columns B, C, G, Y (so column B data must be added to column B in database etc)
    Excel 4) Columns D, X
    when Excel 4 files are processing what is your scenario for column X which you just added in
    Excel 2. Are you going to update it or add new rows here.
    As Arthur has suggested generating your package in code seems the way to go for but before that you need
    to think about all the scenarios.
    Vikash Kumar Singh || www.singhvikash.in

  • TableSorter over more than one columns like Excel

    Hi Experts,
    do you have a example for TableSorter over more than one columns like Excel?
    Thank you very much.
    regards
    Steffen

    Hey,
    Please download the application mentioned in it.
    When i have excuted the application i could find sort enabled for all the columns.
    wdContext.currentContextElement().getTableSorter().sort( wdEvent, wdContext.nodeTableSet() );
    Please check it..
    Jithin
    Edited by: jithin james on Apr 16, 2009 10:47 AM

  • Can't open excel files sent from windows xp pc

    sending excel files from pc via msoffice and when received on imac (mail v2.1) file is a '.dat' file, not a format that excel can open. should be a '.xls' file. file is sent as an attachment to an email from ms outlook on the pc.
    get same result when sending to entourage on the mac.
    msoffice v.X is installed on mac. msoffice 2002 is installed on the pc.
    any ideas on where the problem is would be greatly appreciated.

    I am also using Office for the Mac and I never had such an issue. I have received hundreds of excel files from pc users and same number of files from mac users.
    The problem that you have is somewhere else. You may need to check at :
    http://www.entourage.mvps.org/faq_topic/attachments.html#att7

  • JTables - Right Aligning certain columns

    Hi!
    Im having a major problem! I am using JTable in my prog, but Im finding them very difficult to customise. I am wanting my JTable to have certain Columns(for monetary values) right aligned, as this looks far better when dealing with currency. I have tried implementing this class on my JTable:
    package accpick.overrides;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.*;
    class MyRenderer implements TableCellRenderer
         TableCellRenderer old_renderer;
         MyRenderer(TableCellRenderer old_renderer)     
              this.old_renderer = old_renderer;
         public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int row,int column     )     
         // use the old renderer to render the cell          
         Component c = old_renderer.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
         if(column == 3||column == 4||column == 6)          
              //align right
         // set all other cells to normal          
         else          
              //align left
         return c;
    The problem with this is that getTableCellRendererComponent() returns a Component, and Component does not seem to have a method to align, but JComponent does(setAlignmentX())
    Please can someone help!!!Am i on the right track or am i going about it totally the wrong way?
    THanks
    Nitron999

    Thanks everyone! Your advice got me past the compiler! But Im still having the problem of right aligning the columns! Was my code on the right path, or am i farting in the wind here?
    Does anyone know of any relatively well structured way of doing this?

  • Is there a way to import columns of excel sheet as separate pages in indesign cc?

    The whole problem is in the question.
    Thanks
    Serge

    You can also specify a range when placing the spreadsheet.
    >You can not generate and insert new pages by importing anything.
    Well, that's not true. That's exactly what happens when you import text and autoflow. I don't know any way to make that work with a spreadsheet, though, without scripting. I suspect it would ge relatively easy to script importing columns from Excel on a one column:one page basis, but you need to ask over  in the scripting forum: InDesign Scripting

  • Ability to set column separator character when Exporting Results

    It would be really cool to be able to set the column separator character when using TXT export of the Results panel. Right now it defaults to a comma. If I could set it to be the TAB character, I would be able to export to the clipboard and then paste the clipboard contents directly into Excel. Right now when I paste, all the columns in Excel have a comma at the end of them, except the last column. I am trying to get around having to create a CSV file. I end up with so many temporary CSV file "laying around".
    Mike

    I already have this entered as an enhancement for a post-production release. It came up on a thread where users did not like our current mechanism of using a tab and comma on the data (and just a tab on the column headings which is really a bug). I have requested that we consider allowing the user to provide the delimiter for text export in the future.
    -- Sharon

  • Since updating ios6 i now cant open excel documents sent on my email?

    why cant i open excell documents sent via email since doing io6 update??

    CB,
    When you upgrade the Numbers app, the old version is not deleted. It is your responsibility to assure that you are using the one you want and need. Don't be too hasty in assuming that you are being somehow cheated either. The old version of Numbers is far better than the newer one, except for a few improvements to cross-platform compatibility in the "upgrade".
    Look in Applications for Numbers 3 and in Applications > iWork for Numbers 2.
    Jerry

Maybe you are looking for