Exporting a MySQL table to Excel

My users have asked for the ability to download a MySQL table to an Excel spreadsheet. Being an amateur at all this PHP stuff I googled around and found a script that is supposed to do this. It's failing with "Couldn't select database: Access denied for user 'holli10_tonybabb'@'%' to database '_admin' 1044"
It seems to be picking up an extra "@%" from somewhere
I used the same settings that I successfully used for a CRON backup job.. I'd really appreciate any insight you can suggest. The script is shown below,
Thanks
Tony
<?php
//EDIT YOUR MySQL Connection Info:
$DB_Server = "209.200.244.80";  //your MySQL Server
$DB_Username = "holli10_tonybabb";     //your MySQL User Name
$DB_Password = "abcd1234";    //your MySQL Password
$DB_DBName = "_admin";    //your MySQL Database Name
$DB_TBLName = "volunteers";    //your MySQL Table Name
//$DB_TBLName,  $DB_DBName, may also be commented out & passed to the browser
//as parameters in a query string, so that this code may be easily reused for
//any MySQL table or any MySQL database on your server
//DEFINE SQL QUERY:
//you can use just about ANY kind of select statement you want -
//edit this to suit your needs!
$sql = "Select * from $DB_TBLName";
//Optional: print out title to top of Excel or Word file with Timestamp
//for when file was generated:
//set $Use_Titel = 1 to generate title, 0 not to use title
$Use_Title = 1;
//define date for title: EDIT this to create the time-format you need
$now_date = date('m-d-Y H:i');
//define title for .doc or .xls file: EDIT this if you want
$title = "Dump For Table $DB_TBLName from Database $DB_DBName on $now_date";
Leave the connection info below as it is:
just edit the above.
(Editing of code past this point recommended only for advanced users.)
//create MySQL connection
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password)
or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno());
//select database
$Db = @mysql_select_db($DB_DBName, $Connect)
or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno());
//execute query
$result = @mysql_query($sql,$Connect)
or die("Couldn't execute query:<br>" . mysql_error(). "<br>" . mysql_errno());
//if this parameter is included ($w=1), file returned will be in word format ('.doc')
//if parameter is not included, file returned will be in excel format ('.xls')
if (isset($w) && ($w==1))
$file_type = "msword";
$file_ending = "doc";
}else {
$file_type = "vnd.ms-excel";
$file_ending = "xls";
//header info for browser: determines file type ('.doc' or '.xls')
header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=database_dump.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
/* Start of Formatting for Word or Excel */
if (isset($w) && ($w==1)) //check for $w again
/* FORMATTING FOR WORD DOCUMENTS ('.doc')   */
//create title with timestamp:
if ($Use_Title == 1)
  echo("$title\n\n");
//define separator (defines columns in excel & tabs in word)
$sep = "\n"; //new line character
while($row = mysql_fetch_row($result))
  //set_time_limit(60); // HaRa
  $schema_insert = "";
  for($j=0; $j<mysql_num_fields($result);$j++)
  //define field names
  $field_name = mysql_field_name($result,$j);
  //will show name of fields
  $schema_insert .= "$field_name:\t";
   if(!isset($row[$j])) {
    $schema_insert .= "NULL".$sep;
   elseif ($row[$j] != "") {
    $schema_insert .= "$row[$j]".$sep;
   else {
    $schema_insert .= "".$sep;
  $schema_insert = str_replace($sep."$", "", $schema_insert);
  $schema_insert .= "\t";
  print(trim($schema_insert));
  //end of each mysql row
  //creates line to separate data from each MySQL table row
  print "\n----------------------------------------------------\n";
}else{
/* FORMATTING FOR EXCEL DOCUMENTS ('.xls')   */
//create title with timestamp:
if ($Use_Title == 1)
  echo("$title\n");
//define separator (defines columns in excel & tabs in word)
$sep = "\t"; //tabbed character
//start of printing column names as names of MySQL fields
for ($i = 0; $i < mysql_num_fields($result); $i++)
  echo mysql_field_name($result,$i) . "\t";
print("\n");
//end of printing column names
//start while loop to get data
while($row = mysql_fetch_row($result))
  //set_time_limit(60); // HaRa
  $schema_insert = "";
  for($j=0; $j<mysql_num_fields($result);$j++)
   if(!isset($row[$j]))
    $schema_insert .= "NULL".$sep;
   elseif ($row[$j] != "")
    $schema_insert .= "$row[$j]".$sep;
   else
    $schema_insert .= "".$sep;
  $schema_insert = str_replace($sep."$", "", $schema_insert);
  //following fix suggested by Josue (thanks, Josue!)
  //this corrects output in excel when table fields contain \n or \r
  //these two characters are now replaced with a space
  $schema_insert = preg_replace("/\r\n|\n\r|\n|\r/", " ", $schema_insert);
  $schema_insert .= "\t";
  print(trim($schema_insert));
  print "\n";
?>
<?php /*_____________________END___OF___THE___CODE______________________
get more code from http://www.fundisom.com/phparadise/
___________________________________________________________________*/ ?>

Never mind. The web hosting support people people told me I had my parameters wrong. It works fine now.

Similar Messages

  • Exporting data from table to Excel in a particular format using BSP.

    Hello all,
          I am creating a application in BSP  wherein i have to export data to excel sheet.
      I am able to do that but the output in excel sheet is not formatted. it is displaying the data in a single 
    column. For example, the internal table which i am exporting to excel contains fields "product
    name", "area name", country name", "values". all these should be displayed in different columns.How 
    can i achieve this functionality.A sample code will be of great help..
    Below is the code i hav written for exporting to excel :
         data: l_len type i,
               l_string type string,
               app_type type string,
               file_content type xstring,
               file_mime_type type string.
         create OBJECT cached_response TYPE cl_http_response EXPORTING add_c_msg = 1.
         cached_response->set_data( file_content ).
         cached_response->set_header_field(
                          name = if_http_header_fields=>content_type
                          value = file_mime_type ).
    LOOP AT itab_xls INTO wa_xls.
       CONCATENATE L_STRING wa_xls-product_name
       wa_xls-area_name
       wa_xls-landx
       CL_ABAP_CHAR_UTILITIES=>CR_LF INTO L_STRING SEPARATED BY SPACE.
    ENDLOOP.
      APP_TYPE = 'APPLICATION/MSEXCEL; charset=utf-16le'.
      data: l_xstring type xstring.
    call function 'SCMS_STRING_TO_XSTRING'
        exporting
          text = l_string
          MIMETYPE = 'APPLICATION/MSEXCEL; charset=utf-16le'
        IMPORTING
          BUFFER = l_xstring.
    Add the Byte Order Mark - UTF-16 Little Endian
      concatenate  cl_abap_char_utilities=>byte_order_mark_little
                   l_xstring
                   into l_xstring in byte mode.
       cached_response->set_data( l_xstring ).
       cached_response->set_header_field( name  = if_http_header_fields=>content_type
                                         value = 'APPLICATION/MSEXCEL; charset=utf-16le' ).
    *Set the filename into the response header
       cached_response->set_header_field( name  = 'Content-Disposition'
                                  value = 'attachment; filename=gkb_excel.xls' ).
    *Set the Response Status
       cached_response->set_status( code = 200 reason = 'OK' ).
    *Set the Cache Timeout - 60 seconds - we only need this in the cache
    *long enough to build the page and allow the IFrame on the Client to request it.
       cached_response->server_cache_expire_rel( expires_rel = 60 ).
        CALL FUNCTION 'GUID_CREATE'
        IMPORTING
          ev_guid_32 = guid.
        CONCATENATE runtime->application_url '/' guid '.xls' INTO url.
        cl_http_server=>server_cache_upload( url      = url
                                           response = cached_response ).
    Can anyone help me with some solution.
    Thanks in advance.
    Gurmahima.

    the issue is here
    LOOP AT itab_xls INTO wa_xls.
    CONCATENATE L_STRING wa_xls-product_name
    wa_xls-area_name
    wa_xls-landx
    CL_ABAP_CHAR_UTILITIES=>CR_LF INTO L_STRING SEPARATED BY SPACE.
    ENDLOOP.
    instead do the following
    LOOP AT itab_xls INTO wa_xls.
    CONCATENATE L_STRING wa_xls-product_name ','
    wa_xls-area_name  ','
    wa_xls-landx  ','
    CL_ABAP_CHAR_UTILITIES=>CR_LF INTO L_STRING .
    ENDLOOP.
    and then change the file name extension from xls to csv. it should open properly in excel.
    Note that this is only excel csv file. if you want a proper excel excel file, then
    option one: build a html table with your data into a string and pass it to excel
    option 2: build excel xml using your data into a string and pass it to excel.
    Regards
    Raja

  • How to export data from a Dynpro table to Excel file?

    Hi
    Here I go again. I read the post <b>Looking for example to export data from a DynPro table to Excel file</b> and put the code lines into a Web Dynpro Project where we need to export a dynpro table to Excel file but exactly at line 23 it doesn't recognize <b>workBook = new HSSFWorkbook();</b>
    1     //Declare this in the end between the Begin others block.
    2     
    3     private FileOutputStream out = null;
    4     private HSSFWorkbook workBook = null;
    5     private HSSFSheet hsSheet = null;
    6     private HSSFRow row = null;
    7     private HSSFCell cell = null;
    8     private HSSFCellStyle cs = null;
    9     private HSSFCellStyle cs1 = null;
    10     private HSSFCellStyle cs2 = null;
    11     private HSSFDataFormat dataFormat = null;
    12     private HSSFFont f = null;
    13     private HSSFFont f1 = null;
    14     
    15     //Code to create the Excel.
    16     
    17     public void onActionExportToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    18     {
    19     //@@begin onActionExportToExcel(ServerEvent)
    20     try
    21     {
    22     out = new FileOutputStream("C:/mydirectory/myfiles/testexcel.xls");
    23     workBook = new HSSFWorkbook();
    24     hsSheet = workBook.createSheet("My Sheet");
    25     cs = workBook.createCellStyle();
    26     cs1 = workBook.createCellStyle();
    27     cs2 = workBook.createCellStyle();
    28     dataFormat = workBook.createDataFormat();
    29     f = workBook.createFont();
    30     f1 = workBook.createFont();
    31     f.setFontHeightInPoints((short) 12);
    32     // make it blue
    33     f.setColor( (short)HSSFFont.COLOR_NORMAL );
    34     // make it bold
    35     // arial is the default font
    36     f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    37     
    38     // set font 2 to 10 point type
    39     f1.setFontHeightInPoints((short) 10);
    40     // make it red
    41     f1.setColor( (short)HSSFFont.COLOR_RED );
    42     // make it bold
    43     f1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    44     f1.setStrikeout(true);
    45     cs.setFont(f);
    46     cs.setDataFormat(dataFormat.getFormat("#,##0.0"));
    47     
    48     // set a thick border
    49     cs2.setBorderBottom(cs2.BORDER_THICK);
    50     
    51     // fill w fg fill color
    52     cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);
    53     cs2.setFillBackgroundColor((short)HSSFCellStyle.SOLID_FOREGROUND);
    54     // set the cell format to text see HSSFDataFormat for a full list
    55     cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
    56     cs2.setFont(f1);
    57     cs2.setLocked(true);
    58     cs2.setWrapText(true);
    59     row = hsSheet.createRow(0);
    60     hsSheet.createFreezePane(0,1,1,1);
    61     for(int i=1; i<10;i++)
    62     {
    63     cell = row.createCell((short)i);
    64     cell.setCellValue("Excel Column "+i);
    65     cell.setCellStyle(cs2);
    66     }
    67     workBook.write(out);
    68     out.close();
    69     
    70     //Read the file that was created.
    71     
    72     FileInputStream fin = new FileInputStream("C:/mydirectory/myfiles/testexcel.xls");
    73     byte b[] = new byte[fin.available()];
    74     fin.read(b,0,b.length);
    75     fin.close();
    76     
    77     wdContext.currentContextElement().setDataContent(b);
    78     }
    79     catch(Exception e)
    80     {
    81     wdComponentAPI.getComponent().getMessageManager().reportException("Exception while reading file "+e,true);
    82     }
    83     //@@end
    84     }
    I don't know why this happen? Any information I will appreciate it.
    Thanks in advance!!!
    Tokio Franco Chang

    After test the code lines appears this error stacktrace:
    [code]
    java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook
         at com.sap.tc.webdynpro.progmodel.api.iwdcustomevent.ExportToExcel.onActionAct1(ExportToExcel.java:232)
         at com.sap.tc.webdynpro.progmodel.api.iwdcustomevent.wdp.InternalExportToExcel.wdInvokeEventHandler(InternalExportToExcel.java:147)
         at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
         at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:252)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:392)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:345)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:323)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:865)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:240)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:159)
    Thanks in advance!!!
    Tokio Franco Chang
    [/code]

  • Problem While exporting HTML table to Excel(.CSV) in SharePoint 2010

    Hi ,
    I was exporting HTML table to .CSV file. 
    Problem is if any field contains '>' or '<' symbol then after exporting to .CSV, it was showing like '&gt' and '&lt' and the code is  as below.
    //Export HTML table to CSV 
    function toCSV() {
          var data = document.getElementById('reportstable');
          var csvData = [];
          var tmpArr = [];
          var tmpStr = '';
          for (var i = 0; i < data.rows[0].cells.length; i++) 
            tmpArr.push((data.rows[0].cells[i].innerText || data.rows[0].cells[i].textContent));
          csvData.push(tmpArr.join('\t'));
          for (var i = 1; i < data.rows.length; i++) 
            tmpArr = [];
            for (var j = 0; j < data.rows[0].cells.length; j++) 
            tmpArr.push(data.rows[i].cells[j].innerHTML);
            csvData.push(tmpArr.join('\t'));
          var output = csvData.join('\n');
          SaveContents(output);
    //For saving the file
    function SaveContents(element) {
            if (document.execCommand) {
                var oWin = window.open("about:blank","_blank");
                oWin.document.write(element);
                oWin.document.close();
                var success = oWin.document.execCommand('SaveAs', false, "FilteredReport.xls")
                oWin.close();
    Thanks in Advance

    Hi,
    According to your post, a problem occurred when you exported the HTML table to Excel(.CSV).
    The following code for your reference:
    function toCSV() {
    var data = document.getElementById('reportstable');
    var csvData = [];
    var tmpArr = [];
    var tmpStr = '';
    for (var i = 0; i < data.rows[0].cells.length; i++)
    tmpArr.push((data.rows[0].cells[i].innerText || data.rows[0].cells[i].textContent));
    csvData.push(tmpArr.join('\t'));
    for (var i = 1; i < data.rows.length; i++)
    tmpArr = [];
    for (var j = 0; j < data.rows[0].cells.length; j++)
    tmpArr.push(data.rows[i].cells[j].innerHTML);
    csvData.push(tmpArr.join('\t'));
    var output = csvData.join('\n');
    SaveContents(output.replace(/&lt;/g, '<').replace(/&gt;/g, '>'));
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Export table to excel

    Hi
    plesae see example that I send , its export data from table to excel file and save the excel file in c:
    the main problem I have number with 20 digit and other number with 15 digit , when I save and open in using excel the number look as
    8.9972E+19 and other number is 3.596e+14
    I need to see the number in full format as its look in the table
    89972010311041561435
    359628040266996
    how can I do that
    Thanks 
    Attachments:
    Untitled 4.vi ‏13 KB
    13_10_2014_23_26.xls ‏1 KB

    Elyan_wisam wrote:
    Hi
    I want to do it in labview code , is there option that way
    thanks
    Sure there is a way. Learn ActiveX. There are examples that ship with LabVIEW.
    You'll need to read the relevant sections of the Excel Developer Reference for the version of Excel you have.
    I have linked to Excel 2013 version http://msdn.microsoft.com/en-us/library/office/ee861528%28v=office.15%29.aspx

  • How to send html table to Excel in PSP?

    Hi,
    I am writing a plsql server page program that produces multiple tables. I only want to export only one of the tables to Excel by pressing a button/link if possible. How to do that? Currently, if i right clicked on that table, then choose "Export to Excel" it will prompt me for the username/password to log into my application before exporting to Excel. How can I avoid the username/pw portion and export only that table to Excel.
    If I use the owa_util.mime_header, I can pass the url to it but it will export all the tables in my psp.
    Thanks in advance!
    kwong

    user464216 wrote:
    I am writing a plsql server page program that produces multiple tables. I only want to export only one of the tables to Excel by pressing a button/link if possible. How to do that? Currently, if i right clicked on that table, then choose "Export to Excel" it will prompt me for the username/password to log into my application before exporting to Excel. How can I avoid the username/pw portion and export only that table to Excel.That is a web server authentication issue - not a PL/SQL issue. The web server deems the URL (for the export) as being unauthorised and thus request authentication details from the web browser. This happens before your PL/SQL code is executed. So you cannot deal with this in PL/SQL itself. That base URL is a location definition in the Apache config file - and that is where access to it is configured, together with authentication details.
    Please note that there's also a difference between exporting data in a Microsoft Excel format and exporting data in a CSV (Comma Separated Values) format. CSV is not an Excel format. Never was. It has been around long before Excel existed. So please make sure that you use the correct technical terminology when describing a technical problem. Thanks.

  • How to export message body and data from Table to Excel from outlook 2010

    I usually get Employee announcement in emails and I need to compile excel sheet from all these emails to know change in status of employee from previous line to current line .
    Dear Concerned,
    The change in status of the following employee has been carried out as per following details:
    New Status
    Change in Job
    Effective Date
    01-Feb-2015
    Employee Name
    Ricky ponting
    Employee Code
    4982
    Designation
    Sourcing Executive (Secondment)
    Job Group
    1A
    Department
    Sourcing & Supply Chain
    Unit
    Technology Sourcing
    Division
    Finance
    Location
    sydney
    Reporting Line
    Mr Micheal king
    Note: Ricky Ponting  was previously working as
    Tariff Implementation Support Officer XYZ organization was reporting to
    Mr Robin Sing
    I need working code that export about HTML table data as well last Note : full line so that I can have an excel file of 2000 Employees whoes status have been changed and I can easily sort out from which previous line they were reporting to new line and I
    can get in touch with the new line for any Access rights re-authorization exercise on later stage .
    Currently i am using following code thats working fine with the table extraction but NOTE: line is not being fetched with the following code based on following URL
    https://techniclee.wordpress.com/2011/10/29/exporting-outlook-messages-to-excel/
    Const MACRO_NAME = "Export Messages to Excel (Rev Sajjad)"
    Private Sub ExportMessagesToExcel()
        Dim olkFld As Outlook.MAPIFolder, _
            olkMsg As Outlook.MailItem, _
            excApp As Object, _
            excWkb As Object, _
            excWks As Object, _
            arrCel As Variant, _
            varCel As Variant, _
            lngRow As Long, _
            intPtr As Integer, _
            intVer As Integer
        Set olkFld = Session.PickFolder
        If TypeName(olkFld) = "Nothing" Then
            MsgBox "You did not select a folder.  Operation cancelled.", vbCritical + vbOKOnly, MACRO_NAME
        Else
            intVer = GetOutlookVersion()
            Set excApp = CreateObject("Excel.Application")
            Set excWkb = excApp.Workbooks.Add
            Set excWks = excWkb.Worksheets(1)
            excApp.Visible = True
            With excWks
                .Cells(1, 1) = "Subject"
                .Cells(1, 2) = "Received"
                .Cells(1, 3) = "Sender"
                .Cells(1, 4) = "New Status"
                .Cells(1, 5) = "Effective Date"
                .Cells(1, 6) = "Employee Name"
                .Cells(1, 7) = "Employee Code"
                .Cells(1, 8) = "Designation"
                .Cells(1, 9) = "Job Group"
                .Cells(1, 10) = "Department"
                .Cells(1, 11) = "Unit"
                .Cells(1, 12) = "Division"
                .Cells(1, 13) = "Location"
                .Cells(1, 14) = "Reporting Line"
                .Cells(1, 15) = "Note:"
            End With
            lngRow = 2
            For Each olkMsg In olkFld.Items
                excWks.Cells(lngRow, 1) = olkMsg.Subject
                excWks.Cells(lngRow, 2) = olkMsg.ReceivedTime
                excWks.Cells(lngRow, 3) = GetSMTPAddress(olkMsg, intVer)
               For intPtr = LBound(arrCel) To UBound(arrCel)
                    Select Case Trim(arrCel(intPtr))
                        Case "New Status"
                            excWks.Cells(lngRow, 4) = arrCel(intPtr + 1)
                        Case "Effective Date"
                            excWks.Cells(lngRow, 5) = arrCel(intPtr + 1)
                        Case "Employee Name"
                            excWks.Cells(lngRow, 6) = arrCel(intPtr + 1)
                        Case "Employee Code"
                            excWks.Cells(lngRow, 7) = arrCel(intPtr + 1)
                        Case "Designation"
                            excWks.Cells(lngRow, 8) = arrCel(intPtr + 1)
                        Case "Job Group"
                            excWks.Cells(lngRow, 9) = arrCel(intPtr + 1)
                        Case "Department"
                            excWks.Cells(lngRow, 10) = arrCel(intPtr + 1)
                        Case "Unit"
                            excWks.Cells(lngRow, 11) = arrCel(intPtr + 1)
                        Case "Division"
                            excWks.Cells(lngRow, 12) = arrCel(intPtr + 1)
                        Case "Location"
                            excWks.Cells(lngRow, 13) = arrCel(intPtr + 1)
                        Case "Reporting Line"
                            excWks.Cells(lngRow, 14) = arrCel(intPtr + 1)
                        Case "Note:"
                            excWks.Cells(lngRow, 14) = arrCel(intPtr + 1)
                        End Select
                Next
                lngRow = lngRow + 1
            Next
            excWks.Columns("A:W").AutoFit
            excApp.Visible = True
            Set excWks = Nothing
            Set excWkb = Nothing
            Set excApp = Nothing
        End If
        Set olkFld = Nothing
    End Sub
    Private Function GetSMTPAddress(Item As Outlook.MailItem, intOutlookVersion As Integer) As String
        Dim olkSnd As Outlook.AddressEntry, olkEnt As Object
        On Error Resume Next
        Select Case intOutlookVersion
            Case Is < 14
                If Item.SenderEmailType = "EX" Then
                    GetSMTPAddress = SMTP2007(Item)
                Else
                    GetSMTPAddress = Item.SenderEmailAddress
                End If
            Case Else
                Set olkSnd = Item.Sender
                If olkSnd.AddressEntryUserType = olExchangeUserAddressEntry Then
                    Set olkEnt = olkSnd.GetExchangeUser
                    GetSMTPAddress = olkEnt.PrimarySmtpAddress
                Else
                    GetSMTPAddress = Item.SenderEmailAddress
                End If
        End Select
        On Error GoTo 0
        Set olkPrp = Nothing
        Set olkSnd = Nothing
        Set olkEnt = Nothing
    End Function
    Function GetOutlookVersion() As Integer
        Dim arrVer As Variant
        arrVer = Split(Outlook.Version, ".")
        GetOutlookVersion = arrVer(0)
    End Function
    Function SMTP2007(olkMsg As Outlook.MailItem) As String
        Dim olkPA As Outlook.PropertyAccessor
        On Error Resume Next
        Set olkPA = olkMsg.PropertyAccessor
        SMTP2007 = olkPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x5D01001E")
        On Error GoTo 0
        Set olkPA = Nothing
    End Function
    Sub DebugLabels()
        Dim olkMsg As Outlook.MailItem, objFSO As Object, objFil As Object, strBuf As String, strPth As String, arrCel As Variant, intPtr As Integer
        strPth = Environ("USERPROFILE") & "\Documents\Debugging.txt"
        Set olkMsg = Application.ActiveExplorer.Selection(1)
        arrCel = Split(GetCells(olkMsg.HTMLBody), Chr(255))
        For intPtr = LBound(arrCel) To UBound(arrCel)
            strBuf = strBuf & StrZero(intPtr, 2) & vbTab & "*" & arrCel(intPtr) & "*" & vbCrLf
        Next
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objFil = objFSO.CreateTextFile(strPth)
        objFil.Write strBuf
        objFil.Close
        Set olkMsg = Application.CreateItem(olMailItem)
        With olkMsg
            .Recipients.Add "[email protected]"
            .Subject = "Debugging Info"
            .BodyFormat = olFormatPlain
            .Body = "The debugging info for the selected message is attached.  Please click Send to send this message to David."
            .Attachments.Add strPth
            .Display
        End With
        Set olkMsg = Nothing
        Set objFSO = Nothing
        Set objFil = Nothing
    End Sub
    Function StrZero(varNumber, intLength)
        Dim intItemLength
        If IsNumeric(varNumber) Then
            intItemLength = Len(CStr(Int(varNumber)))
            If intItemLength < intLength Then
                StrZero = String(intLength - intItemLength, "0") & varNumber
            Else
                StrZero = varNumber
            End If
        Else
            StrZero = varNumber
        End If
    End Function

    Dear Graham
    I am already big fan of yours and using mail to many Addin from years from word 2007 to Word 2010 :) and still loving it and I use it for access re-authorization from Lines for application accesses . I tried and finally got understanding of the Extract to
    mail Addin and after tweaking excel - Text To columns and other few things finally i was able to get the required data - from morning to now :) I am happy to see your provided guidance
    Thanks alot - by the way why your Mail to many add-in is so slow now these days :) previous versions usually help me send 1000 emails in 10 minutes now it takes long time :)

  • How to export a table in excel (in JSP)???

    hi all,
    I am using AJAX functionality in jsp to export a table into Excel.But i don't want to use it as it gives a hyperlink whereas i want a button which should work similar to hypelink.
    I mean to say i want a saperate export button which should work similar to the hyperlink.
    if anybody has any idea abt it....plz reply it soon.......

    So what you want to do is redirect to a page when the user clicks the button?
    So just put the button in a form with the action attribute set to wherever the hyperlink points now.
    And in case the button is already a part of a form, then on the onClick() event of the button, change the action attribute of the form to this particular hyperlink target and then cause it to submit.
    That ok?
    Or do you want the Excel file you're generating to be sent to the browser causing it to popup a dialog asking the user to save or open? If so take a look here http://forum.java.sun.com/thread.jspa?threadID=5170452&messageID=9655276

  • How to export the data from table to excel sheet

    hi experts i have some problem am trying to export the data fro table to Excel sheet  in the view controller i have created one button wit public void onActionCLEAR(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionCLEAR(ServerEvent)
       //wdContext.nodeBapi_Salesorder_Getlist_Input().
       //wdContext.nodeBapi_Salesorder_Getlist_Input().invalidate();
        //@@end
      //@@begin javadoc:onActionExporToExcel(ServerEvent)
      /** Declared validating event handler. */
      //@@end
      public void onActionExporToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionExporToExcel(ServerEvent)
         try{
         FileOutputStream fos=new FileOutputStream("Test.xls");
          PrintStream ps=new PrintStream(fos);
          ps.println("<html><body><table border=1>");
          int size=wdContext.nodeBapi_Salesorder_Getlist_Input().size();
           Iterator attributes=wdContext.getNodeInfo().iterateAttributes();
           ps.println("<tr>");
           while(attributes.hasNext()){
            ps.println("<th>");
            DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();
            ps.println(attrName.getName());
            ps.println("</th>");
           ps.println("</tr>");
          for(int i=0; i<wdContext.nodeBapi_Salesorder_Getlist_Input().size();i++)
            attributes=wdContext.getNodeInfo().iterateAttributes();
            ps.println("<tr>");
            IWDNodeElement ele=wdContext.getElementAt(i);
            while(attributes.hasNext()){
              ps.println("<td>");
              DataAttributeInfo attrName=(DataAttributeInfo)attributes.next();
              ps.println(""+ele.getAttributeAsText(attrName.getName()));
              ps.println("</td>");
            ps.println("</tr>");
           ps.println("</table></body></html>");
           ps.flush();
           ps.close();
           fos.close();
          catch(Exception e){
           wdComponentAPI.getMessageManager().reportException(e.getMessage(), false);
          finally{
         //return("Test.xls")  ;
        //@@end
      }h action and i have return the code
    its running sucessfully but am not able to perform the action plz help me

    Hi,
    You shouldn't use DataAttributeInfo as it is an internal object, if I'm correct.
    Use IWDAttributeInfo instead of DataAttributeInfo and it should work
    (See also API doc of IWDNodeInfo.iterateAttributes() at http://help.sap.com/javadocs/nwce/ce711sp02/wdr/com.sap.wdr/com/sap/tc/webdynpro/progmodel/api/IWDNodeInfo.html#iterateAttributes())
    Cheers,
    Robin

  • Problem while exporting ADF table to excel

    Hello,
    I have some columns of random size which are left padded with 0.
    now the problem comes when I export the table containing these columns to excel, excel remove all those zeros from left.
    eg: 000000003726819563(table column value) after exporting to excel shows as 3726819563.
    Along with this I also want the footer part of table in excel.
    For some of the columns I have summary filed(i.e. sum) at the footer of the table which I want to show in excel.
    Can someone please guide me through these issues.
    Thanks in advance.

    Take a look at this: http://adfreusablecode.blogspot.com/2012/07/export-to-excel-with-styles.html
    With this code you can export the footer: http://dl.dropbox.com/u/22312971/adf-samples/ExportToExcelDemo/ViewController/src/view/ExcelBean.java
    Here is the entire demo project: http://dl.dropbox.com/u/22312971/adf-samples/ExportToExcelDemo.zip
    I a few days I will update the above post.
    Hope this help.
    AP

  • Export Transient Attribute data to excel sheet (from Advance Table)

    Hi,
    I have an advanced table in which its columns mapped with both vo attributes(from database) and transient attributes. If i select 'Export Button' i need to export all data present in the advanced table to excel sheet.. But i am not able to export transient attribute data .. Can anyone help me to solve this problem...
    Thanks,
    Babu

    Babu
    You should be able to export any attribute from the VO, provided they are not hidden fields. Do the values appear on the screen? What is the field type on the advanced table of the attribute you are trying to export?
    --Ritu                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Acrobat 8 Pro Export Table to Excel

    Using Professional 8 and I cannot seem to get this table in PDF exported to Excel or any other format I can open in Excel.  I've read and followed multiple help files out there but the selections I'm supposed to have aren't available...
    I set my page to continuous view.  I am using the proper select tool.  I select from upper left to bottom right on a single page.  I mouse over highlighted word and right click.  I do NOT have the "open table in excel" option.
    I also tried Advanced / Accessibility... but "Add Tags to Document" is greyed out.
    This is not a scanned document. It's clearly a table.
    I've tried copy / copy with formatting from my right click menu but when I paste in Excel, it's not in a format I can use the "text to columns" for because the columns are separated by only one space.  So it puts a column in between multiple words in a single column.
    HELP!
    Thanks in advance!

    There are options called "Copy as table", "Save as table" and "Open table as
    spreadsheet" (which will open the table in Excel), but you must select the
    table with Alt pressed down.

  • Problem export pdf table to excel spreadsheed

    Hi, my name is Marco.
    Last month a customer has bought a copy of Adobe Acrobat Professional 9 in my computer shop for edit some pdfs files.
    After some days he told me that he need to export a table to excel's spreadsheet but the function "open table in excel spreadsheet" work ONLY for the page where i right-click. How can i copy all the document in excel (without lose the format)?
    Sorry for the bad english, if you don't understand i try to rewrite it better or in Italian!
    Thank you!

    A lot depends on the structure of the PDF. I it has tags included that provide the format information, then the conversion may be easy. If the tags are not included, then retaining the format is almost impossible. This may even be a problem with recognizing columns. In that case, selecting columns with the ctrl key held during the selection. More information is available under "Copying Text" in the help menu (complete help). The help also talks about the ability to retain format as I have suggested.
    To select items on multiple pages, you have to use continuous view.
    It might be easier to the Save As to DOC and go from there. The backward conversion is not the forte or intent of Acrobat. In reality, one should never delete the original XLS (or other) file with the intent of going back in the future. Sounds like it is too late for your customer.

  • Export internal table to Excel during debugging.

    Hi Experts
    I have put a debugger( old debugger ) on a certain line of code where we are checking  the  data of an internal table having around 10000 entries and I want to export this internal table data to an excel for analysis during debugging itself.
    Is there a way to export this ? The new debugger does not work in IFD. ( 6.40)
    Regards
    Sukanya.

    Hi
    In application menu follow the path
    Select the internal table then
    Goto->Display Data Object -> Structure Editor
    This will show only part of the internal.
    Goto List-> Display entire list.
    You can print the list or send it to excel sheet.
    Regards
    Navneet

  • Exporting data in tables to an Excel spreadsheet?

    Is there a script or another way to export or save a documents tables (multiple tables over several pages) to an excel spreadsheet? I have found a solution which involves exporting each spread as a html file which i can then open straight in excel but this is still quite long winded and i can only seem to do this a spread at a time. As the job I am working on involves many pages this is taking too long. Surely there must be a script which can automate this in some way. I am fairly new to scripting so any help will be grateful. I have searched in scripting but nothing has really come close to what i am trying to achieve. Indesign CS5.5 user.

    Thanks for the quick response. I thought it was an applescript because of the word "applescript" within it. Now I'm running it as a jsx. However in my real document with nothing selected, it selects only one table on page 3 to export. I created a new test document with three tables in separate text boxes on one page, and the script only exports the first one. I put the three tables in one big text box (one story), and still it only exports the first one. I tried selecting the second table in the story and ran the script again, but it still just exported the first table.
    What I am hoping for is a script that will export every table to a single excel spreadsheet. Here is an example of the dummy tables with the legend in the first column and the data in the second column. I don't mind if the script exports the legend every time; I can repmove those columns in the excel file.
    1
    a
    2
    b
    3
    c
    4
    d
    5
    e
    6
    f
    7
    g
    8
    h
    1
    i
    2
    j
    3
    k
    4
    l
    5
    m
    6
    n
    7
    o
    8
    p
    1
    q
    2
    r
    3
    s
    4
    t
    5
    u
    6
    v
    7
    w
    8
    x

Maybe you are looking for

  • Problems with FIOS and certain programs

    when i try to use LIMEWIRE or a TORRENT program such as utorrent...the router will shut itself down n restart, ive tried portforwarding to no availe, it will happen on all my computers 1 lap top is running windows 7 and 1 desk top is running windows

  • PO print OUT And material Document Print Out is coming In English

    HI all. I have Created Vendor In ZH(chinese Language,)and in material master I have maintained description in Chinese language. I'M taking PO and material Documents print outs  in Chinese Server log-in. even Though Im taking Print outs in Chinese Log

  • Sims 3 performance improve with Snow Leopard?

    When playing the Sims 3, to prevent major lagging, I have to have all the graphics set to the lowest possible setting. The graphics are a huge part of the game so this has been rather disappointing. My specs: White MacBook Jan 2008 OS X 10.5.8 2 GHz

  • ICloud only sync selective contacts from iPhone

    This problem has been driving me crazy for the past 2 weeks. Allow me to give you the full story so that you can help me. Since iCloud became online I had no issues syncing outlook on Windows XP , iPhone and iPad contacts , calendars and notes. Howev

  • Running PSE7.0 on Win 7. Can I transfer to Windows 8.1?

    I am running Windows 7 with Photoshop Elements 7.0.  Can I transfer this to a  second Windows 8.1 system?