Export data to excel and table column headers
I noticed that with LV 2012 when I call the method "Export Data to Excel" for a table, the table headers (= column names) are not exported to excel.
Am I right? I think that the column names should be exported too...
As a matter of fact when you call the method "Export to simplified image" the column names are included
How can I export the table column names to excel?
Vix
In claris non fit interpretatio
Using LV 2013 SP1 on Win 7 64bit
Using LV 8.2.1 on WinXP SP3
Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
Using CVI 6.0 on Win2k, WinXP and WinXP Embedded
In this document there is a full description of how to export data from LabVIEW to Excel.
Using a table, the method "Export data to excel" should export the "currently selected data", and data can be programmatically selected using ActiveCell property (as described here).
With ActiveCell I can select the column headers too (using negative numbers for row and/or column), and I do this.
And so I expect that when I select "Export data to Excel", the column headers should be exported too (because I selected them!).
I think that the actual behavior is a bug, rather that an expected behavior.
Don't you agree?
Vix
In claris non fit interpretatio
Using LV 2013 SP1 on Win 7 64bit
Using LV 8.2.1 on WinXP SP3
Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
Using CVI 6.0 on Win2k, WinXP and WinXP Embedded
Similar Messages
-
Missing Header Row When Exporting Data to Excel and Program Runs Slow
Hello all,
I am new to programming. I’ve dabbled with VB.NET at times over the years but this is the first time I’m trying C#. Although, it’s been quite a while since I’ve done any type of programming other than writing SQL queries at work. For the sake of trying to
learn I have given myself a project that is something I can actually use at work. Right now I'm doing it at home. I’m querying a database on SQL Server 2008 R2; putting the data from the DB into a DataViewGrid and then exporting the data into Excel and saving
the file on my C:\ drive. On the form I have two buttons; one that queries the DB and the other to do the export. The code below does work but I have two issues that I need assistance with:
All of the SQL table data goes into Excel properly with the exception of it is missing the header row.
After I click the Export button it takes a long time to create the Excel file. It takes between 2.5 and 3 minutes. It is not a big file (only 447 rows and 125 KB in size) so I don’t know why it takes so long. Does it have anything to do with the number
of times Microsoft.Office.Interop.Excel is being referenced? I read somewhere online that is an old COM method although I’m not familiar with what a COM method is
and why it would make things run so slow.
When I click the button to run the SQL query and load the DataGridView it runs immediately.
I plan on taking this project further such as adding date parameters including validation on the dates and then maybe adding buttons that can be used to insert, update and delete records. But I don’t want to go any further until the two issues mentioned
above are resolved. Any assistance / guidance will be greatly appreciated. Here’s the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using Exccel = Microsoft.Office.Interop.Excel;
using System.IO;
namespace Bills_DB_DataGridView
public
partial
class
Form1 :
Form
SqlCommand sqlCMD;
SqlDataAdapter sqlDA;
SqlCommandBuilder sqlCB;
DataSet sqlDS;
DataTable sqlDT;
public Form1()
InitializeComponent();
private
void btnExit_Click(object sender,
EventArgs e)
this.Close();
private
void btnLoad_Click(object sender,
EventArgs e)
string sqlCon =
"Data Source = localhost\\DAVE_DB; Initial Catalog=Bills;Integrated security = true;";
string sqlQry =
"SELECT * FROM Acct ORDER BY Name, PaymentDate";
SqlConnection connection =
new
SqlConnection(sqlCon);
connection.Open();
sqlCMD = new
SqlCommand(sqlQry, connection);
sqlDA = new
SqlDataAdapter(sqlCMD);
sqlCB = new
SqlCommandBuilder(sqlDA);
sqlDS = new
DataSet();
sqlDA.Fill(sqlDS, "Acct");
sqlDT = sqlDS.Tables["Acct"];
connection.Close();
dataGridView1.DataSource = sqlDS.Tables["Acct"];
dataGridView1.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
private
void btnExport_Click(object sender,
EventArgs e)
Microsoft.Office.Interop.Excel.Application xlApp;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
Int32 i, j;
xlApp = new Microsoft.Office.Interop.Excel.Application();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
for (i = 0; i <= dataGridView1.RowCount - 2; i++)
for (j = 0; j <= dataGridView1.ColumnCount - 1; j++)
xlWorkSheet.Cells[i + 1, j + 1] = dataGridView1[j, i].Value.ToString();
xlWorkSheet.Cells[1, 2].EntireColumn.NumberFormat = "@";
//Format column 2 to text
xlWorkSheet.Cells[1, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
xlWorkBook.SaveAs(@"c:\Bills\Bills.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal,
misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
private
void releaseObject(object obj)
try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
obj = null;
catch (Exception ex)
obj = null;
MessageBox.Show("Exception Occured while releasing object "
+ ex.ToString());
finally
GC.Collect();
Thank you,
Dave
David YoungHello again Kristin,
I tried the code snippet to include the headers in the Excel file but it didn't work for me. Maybe I put the code in the wrong place? Again I have put the code below including where I placed the snippet. I get no error message and the application runs. Am
I doing something wrong?
Thank you,
Dave
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using Exccel = Microsoft.Office.Interop.Excel;
using System.IO;
namespace Bills_DB_DataGridView
public partial class Form1 : Form
SqlCommand sqlCMD;
SqlDataAdapter sqlDA;
SqlCommandBuilder sqlCB;
DataSet sqlDS;
DataTable sqlDT;
public Form1()
InitializeComponent();
private void btnExit_Click(object sender, EventArgs e)
this.Close();
private void btnLoad_Click(object sender, EventArgs e)
string sqlCon = "Data Source = localhost\\DAVE_DB; Initial Catalog=Bills;Integrated security = true;";
string sqlQry = "SELECT * FROM Acct ORDER BY Name, PaymentDate";
SqlConnection connection = new SqlConnection(sqlCon);
connection.Open();
sqlCMD = new SqlCommand(sqlQry, connection);
sqlDA = new SqlDataAdapter(sqlCMD);
sqlCB = new SqlCommandBuilder(sqlDA);
sqlDS = new DataSet();
sqlDA.Fill(sqlDS, "Acct");
sqlDT = sqlDS.Tables["Acct"];
connection.Close();
dataGridView1.DataSource = sqlDS.Tables["Acct"];
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
private void btnExport_Click(object sender, EventArgs e)
Microsoft.Office.Interop.Excel.Application xlApp;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
Int32 i, j;
xlApp = new Microsoft.Office.Interop.Excel.Application();
xlWorkBook = xlApp.Workbooks.Add(misValue);
// storing header part in Excel
xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
for (int h = 1; h < dataGridView1.Columns.Count + 1; h++)
if (dataGridView1.Columns[h - 1].Visible)
xlWorkSheet.Cells[1, h] = dataGridView1.Columns[h - 1].HeaderText;
xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
for (i = 0; i <= dataGridView1.RowCount - 2; i++)
for (j = 0; j <= dataGridView1.ColumnCount - 1; j++)
xlWorkSheet.Cells[i + 1, j + 1] = dataGridView1[j, i].Value.ToString();
xlWorkSheet.Cells[1, 2].EntireColumn.NumberFormat = "@"; //Format column 2 to text
xlWorkSheet.Cells[1, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
xlWorkBook.SaveAs(@"c:\Bills\Bills.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,
misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
private void releaseObject(object obj)
try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
obj = null;
catch (Exception ex)
obj = null;
MessageBox.Show("Exception Occured while releasing object " + ex.ToString());
finally
GC.Collect();
David Young -
Export data to excel from table
Hi experts,
Scenario: I have a table which is mapped to a context node consisting of 6 attributes. Here I want to add a new button to the application to export all the data comming in the table to an excel sheet. How can i achieve this scenario. I need the least complicated and the shortest method(code) to implement the same.
Please help me with this.
Regards,
KMHi KM,
Please refer to below documents :
https://wiki.sdn.sap.com/wiki/label/excel
http://wiki.sdn.sap.com/wiki/display/WDJava/ExporttoExcel(WithoutthirdpartyAPIs)
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d01854fd-1579-2c10-63ad-dd62edca2381?quicklink=index&overridelayout=true
Regarding Download data in MS Excel format and Check box
Hope it helps
Regards
Arun -
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 ChangAfter 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] -
Workflow for exporting xml from Excel and importing into table in InDesign
Hello,
I have worked out how to get data from a .xlsx into a table in InDesign. However, the workflow is still a little clunky and I am looking for way to automate the process further. My current workflow is as follows (files can be download here: http://visual360.co.uk/xml.zip)
xml is exported from .xlsx by mapping the schema (see what_I_get.xml)
assign tags to table and individual cells in InDesign
This is the clunky bit: edit the what_I_get.xml to:
remove the indentation (this seems necessary as otherwise when I get to stage 4, all the imported text is also indented)
add tag for table in InDesign (p10_table)
add tags for individual cells (p10_c11 etc.)
import the produced what_I_want.xml in the structure panel of InDesign.
Can anyone point me in the direction of how to automate step 3 above?
Thanks in advance,
NickHi Mike,
Thanks very much for the reply. I am not at all familiar with XSL/XSLT. I have given it a quick google and it seems like it could be quite a steep learning curve to master. Maybe if I explain the whole context here, it may allow you to point me in the direction of a tutorial that provides a step by step approach to achieve my final goal. Alternatively, you may be able to suggest a whole new workflow.
I am in the process of updating this document: http://www.ncl.ac.uk/students/insessional/assets/documents/IS_Brochure_2014-15.pdf
The tables on pages 10-21 contain lots and lots of repeated information. We want the layout to in this format so that each group of students has all the information relevant to them on a single double spread. However, the challenge of using this approach is that it is very high maintenance to ensure the duplicated information is kept in sync - even using a copy / paste approach.
I was hoping to overcome this by using a single source of data (eg. a spreadsheet) which would then feed into the InDesign. This workflow seems to be overcomplicated by the apparent need to use xml as the "middle-man".
Ideally, I would like to press the export button in Excel and get this information into the the correct cells in the tables on pages 10-21 without a significant amount of manual labour - after all, my reasons for investigating an automated approach in the first place was to avoid the manual entering of data ie. the scope for error...
An alternative approach maybe to skip Excel altogether and just use .xml. However, I am not sure that this is possible as Indesign only seems to allow you to import each element once. Maybe you could correct me here...
I am happy to invest a certain amount of time in developing this approach as once it is in place, it will save a huge of proof-reading time year after year, especially as inconsistencies still persist despite our best efforts to weed them out.
If you could let me know your thoughts on this and maybe identify a tutorial that would help me, I would be extremely grateful.
Thanks again!
Nick -
Problem in exporting data to excel in nwds 7.3
Hi All,
I was using the following code for exporting data to excel in NWDS 7.3
private IWDCachedWebResource getCachedWebResource(byte[] file, String name,
WDWebResourceType type) {
IWDCachedWebResource cachedWebResource = null;
if (file != null) {
cachedWebResource = WDWebResource.getWebResource(file, type);
cachedWebResource.setResourceName(name);
return cachedWebResource;
I was getting the error in the following line cachedWebResource = WDWebResource.getWebResource(file, type); when I clicked the quick help it ststed the getWebResource method is depricated. Kindly provide some assistance on what is the new method in its place.
Thank you
Regards,
Preet KaurHi Ganesh,
Thanks that worked fine, but when we go further we are facing problem ie
byte[] excelXMLFile;
IWDCachedWebResource cachedExcelResource = null;
String fileName = dataNode.getNodeInfo().getName() + ".xls";
try {
// create Excel 2003 XML data as a byte array for the given context node,
// attributes and headers
excelXMLFile = toExcel(dataNode, columnInfos).getBytes("UTF-8");
// create a cached Web Dynpro XLS resource for the given byte array
// and filename
cachedExcelResource = getCachedWebResource(
excelXMLFile, fileName, WDWebResourceType.XLS);
// Store URL and file name of cached Excel resource in context.
if (cachedExcelResource != null) {
wdContext.currentContextElement().setExcelFileURL(
cachedExcelResource.getURL());
wdContext.currentContextElement().setExcelFileName(
cachedExcelResource.getResourceName());
// Open popup window with a link to the cached Excel file Web resource.
openExcelLinkPopup();
} else {
wdComponentAPI.getMessageManager().reportException(
"Failed to create Excel file from table!", true);
} catch (UnsupportedEncodingException e) {
wdComponentAPI.getMessageManager().reportException(
e.getLocalizedMessage(), true);
} catch (WDURLException e) {
wdComponentAPI.getMessageManager().reportException(
e.getLocalizedMessage(), true);
The above bold lines also would need to be converted to inputstream, but not sure how to correct that
We are following the below pdf for the implementation.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/edc2f3c2-0401-0010-8898-acd5b6a94353?QuickLink=index&overridelayout=true
Thank you
Regards,
Jaspreet Kaur -
hi everybody ,
could you give me an example about export data to excel with no ole objects?You can use FM - ALV_XXL_CALL , it exports the data with formatting and column heading.
REPORT ZSKC_ALV_XXL.
TYPE-POOLS : KKBLO.
DATA : ITAB LIKE T100 OCCURS 0,
T_FCAT_LVC TYPE LVC_S_FCAT OCCURS 0 WITH HEADER LINE,
T_FCAT_KKB TYPE KKBLO_T_FIELDCAT.
START-OF-SELECTION.
* Get data.
SELECT * UP TO 20 ROWS
FROM T100
INTO TABLE ITAB
WHERE SPRSL = SY-LANGU.
CHECK SY-SUBRC EQ 0.
* Create the field catalog.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'T100'
CHANGING
CT_FIELDCAT = T_FCAT_LVC[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
CHECK SY-SUBRC EQ 0.
* make sure you pass the correct internal table name in the field catalog.
t_fcat_lvC-tabname = 'ITAB'.
MODIFY T_FCAT_LVC TRANSPORTING TABNAME WHERE TABNAME NE SPACE.
* Transfer to KKBLO format.
CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
EXPORTING
IT_FIELDCAT_LVC = T_FCAT_LVC[]
IMPORTING
ET_FIELDCAT_KKBLO = T_FCAT_KKB
EXCEPTIONS
IT_DATA_MISSING = 1
IT_FIELDCAT_LVC_MISSING = 2
OTHERS = 3.
CHECK SY-SUBRC EQ 0.
* Call XXL.
CALL FUNCTION 'ALV_XXL_CALL'
EXPORTING
I_TABNAME = 'ITAB'
IT_FIELDCAT = T_FCAT_KKB
TABLES
IT_OUTTAB = ITAB[]
EXCEPTIONS
FATAL_ERROR = 1
NO_DISPLAY_POSSIBLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF. -
Export data to excel scientific notation
Hello,
How can I export data to excel such as 9900007600000018463000, 9900007600000018473000, etc. without transforming them into scientific numbers like 9,90000760000001E+21 ?
Thank you for your helpSorry that my suggestion did not work. I have experimented with excel and could not get it to retain the precision on very large numbers for any numeric formatted fields. The idea I have for you is to create a table with your big number column defined as varchar2. Copy the data from the original table into the new table "insert into bignumber_varchar_table varchar_column select bignumber_table from bignumber;". Then do the export from the new table. This will keep the data as text and then excel retains the precision. Because it is text it will be displayed left justified. Right click and choose format cell, click on alignment, and set horizontal to right if you want it to look like a number in the spread sheet. Unfortunately, if you try to do calculations with it, the calculation appears to loose the precision.
-
Problem while exporting data to Excel sheet.......
Hi
I have written the following code to export data to excel sheet...
data:
conv_out TYPE REF TO cl_abap_conv_out_ce,
content TYPE xstring.
data : itab_slsrl type table of znslsrlitm.
data: xml_out TYPE string.
Data:
Node_slsrl type ref to If_Wd_Context_Node,
Elem_slsrl type ref to If_Wd_Context_Element,
Stru_slsrl type ref to if_wd_context_element .
call transformation ('ID') source tab = itab_slsrl[] result xml xml_out.
CALL FUNCTION 'CRM_IC_XML_STRING2XSTRING'
EXPORTING
INSTRING = xml_out
IMPORTING
OUTXSTRING = content.
conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
DATA: lv_filename TYPE string.
conv_out->convert( exporting data = xml_out IMPORTING buffer = content ).
cl_wd_runtime_services=>attach_file_to_response(
i_filename = 'Sales_order_release.xls'
i_content = content
i_mime_type = 'application/msexcel'
i_in_new_window = i_in_new_window
i_inplace = i_inplace ).
But when i am trying to export data to excel sheet i am getting
following error...
"Switch from current encode to specified encoding is not supported"
"<?xml version="1.0" encoding='utf-16"?>"
if i change encoding utf-8 to utf-16 in my code its giving dump..
"The conversion of certain code pages is not supported"
Did i miss any step...?
How to resolve this problem please help me....
Thanks & Regards
Sowmya.....Hi Sowmya,
I do had a similar issue, but I avoided that problem temporarily by commenting the following code.
l_conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
attach the first file
l_conv_out->convert( exporting data = l_xml_out IMPORTING buffer = l_content ).
Once this is done, you can export the data to Excel and open it and see too...But this is a temporary solution only. Implement this solution to get to understand more flaws of this.
Regards
Raja Sekhar
Edited by: Raja Sekhar on Dec 26, 2007 7:51 PM -
Exporting Data Of an RDBMS Table to another RDBMS Table using ODI Functions
Hi,
I'm facing a problem while Exporting Data Of an RDBMS Table to another RDBMS Table using ODI User Functions.
Name:- User_Func
Group:- Training
Syntax:- User_Func($(SrcField))
Implementation Syntax:-
(CASE
WHEN $(SrcField) > 40000 THEN 'HIGH'
WHEN $(SrcField) BETWEEN 30000 AND 40000 THEN 'MEDIUM'
ELSE 'LOW'
Linked Technology:-Oracle
To map the GRADE column of my TARGET_EMPTABLE I write
User_Func(SRC_TABLENAME.SALARY)
using Expression Editor.
I got the following error
ODI-1227: Task ODI_FUNC_INTERFACE (Export) fails on the source ORACLE connection Source_DataServer.
Caused By: java.sql.SQLSyntaxErrorException: ORA-00905: missing keyword
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:947)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1283)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1441)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3769)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3823)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1671)
at oracle.odi.query.JDBCTemplate.executeQuery(JDBCTemplate.java:189)
at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:89)
at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:1)
at oracle.odi.runtime.agent.execution.DataMovementTaskExecutionHandler.handleTask(DataMovementTaskExecutionHandler.java:70)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:558)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:464)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2093)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
at java.lang.Thread.run(Thread.java:619)
and in code tab it is:-
select
SRC_FUNC_TABLE.E_NUMBER E_NUMBER,
SRC_FUNC_TABLE.E_NAME E_NAME,
SRC_FUNC_TABLE.E_LOC E_LOC,
(CASE
WHEN SRC_FUNC_TABLE.E_SAL > 40000 THEN 'HIGH'
WHEN SRC_FUNC_TABLE.E_SAL BETWEEN 30000 AND 40000 THEN 'MEDIUM'
ELSE 'LOW'
) E_GRADE
from SOURCE_SCHEMA.SRC_FUNC_TABLE SRC_FUNC_TABLE
where (1=1)
Please HelpAnindya Chatterjee wrote:
Hi,
I'm facing a problem while Exporting Data Of an RDBMS Table to another RDBMS Table using ODI User Functions.
Name:- User_Func
Group:- Training
Syntax:- User_Func($(SrcField))
Implementation Syntax:-
(CASE
WHEN $(SrcField) > 40000 THEN 'HIGH'
WHEN $(SrcField) BETWEEN 30000 AND 40000 THEN 'MEDIUM'
ELSE 'LOW'
)Your CASE statement syntax is not correct
It is missing an END key word
It should be
(CASE
WHEN $(SrcField) > 40000 THEN 'HIGH'
WHEN $(SrcField) BETWEEN 30000 AND 40000 THEN 'MEDIUM'
ELSE 'LOW'
END )
Linked Technology:-Oracle
To map the GRADE column of my TARGET_EMPTABLE I write
User_Func(SRC_TABLENAME.SALARY)
using Expression Editor.
I got the following error
ODI-1227: Task ODI_FUNC_INTERFACE (Export) fails on the source ORACLE connection Source_DataServer.
Caused By: java.sql.SQLSyntaxErrorException: ORA-00905: missing keyword
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:947)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1283)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1441)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3769)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3823)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1671)
at oracle.odi.query.JDBCTemplate.executeQuery(JDBCTemplate.java:189)
at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:89)
at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:1)
at oracle.odi.runtime.agent.execution.DataMovementTaskExecutionHandler.handleTask(DataMovementTaskExecutionHandler.java:70)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:558)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:464)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2093)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
at java.lang.Thread.run(Thread.java:619)
and in code tab it is:-
select
SRC_FUNC_TABLE.E_NUMBER E_NUMBER,
SRC_FUNC_TABLE.E_NAME E_NAME,
SRC_FUNC_TABLE.E_LOC E_LOC,
(CASE
WHEN SRC_FUNC_TABLE.E_SAL > 40000 THEN 'HIGH'
WHEN SRC_FUNC_TABLE.E_SAL BETWEEN 30000 AND 40000 THEN 'MEDIUM'
ELSE 'LOW'
) E_GRADE
from SOURCE_SCHEMA.SRC_FUNC_TABLE SRC_FUNC_TABLE
where (1=1)
Please Help -
PROBLEM IN EXPORTING DATA FROM A RELATIONAL TABLE TO ANOTHER RELATIONAL TAB
Hi,
While trying to export data from a source table to a target table, problem occurs with loading the data in the work table(SrcSet0)[As shown in the operator]. The Work Table has been dropped and created successfully, the problem is coming with loading the data( in this work table(SrcSet0)). The error details as mentioned below. Please advise:-
ODI-1227: Task SrcSet0 (Loading) fails on the source ORACLE connection ORACLE_SOURCE.
Caused By: java.sql.SQLException: SQL string is not Query
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1442)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3752)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3806)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1667)
at oracle.odi.query.JDBCTemplate.executeQuery(JDBCTemplate.java:189)
at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:89)
at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:1)
at oracle.odi.runtime.agent.execution.DataMovementTaskExecutionHandler.handleTask(DataMovementTaskExecutionHandler.java:67)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2906)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2609)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:537)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:453)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1740)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:338)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:214)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:272)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:263)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:822)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:123)
at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
at java.lang.Thread.run(Thread.java:662)
Thanks
AnindyaHi actdi,
This is my KM_IKM SQL Incremental Update.xml code:-
and I have find it(for (int i=odiRef.getDataSetMin(); i <= odiRef.getDataSetMax(); i++)) and high lighted it(Bold Text).
So, please advise.
Here is the main part of this code because the code is too long to post.It exceeds maxlength for the msg.
So here it is:
<Object class="com.sunopsis.dwg.dbobj.SnpTxtHeader">
<Field name="Enc" type="java.lang.String">null</Field>
<Field name="EncKey" type="java.lang.String">null</Field>
<Field name="ITxt" type="com.sunopsis.sql.DbInt"><![CDATA[1695003]]></Field>
<Field name="ITxtOrig" type="com.sunopsis.sql.DbInt"><![CDATA[102]]></Field>
<Field name="SqlIndGrp" type="java.lang.String"><![CDATA[2]]></Field>
<Field name="Txt" type="java.lang.String"><![CDATA[insert into <%=odiRef.getTable("L","INT_NAME","A")%>
<%=odiRef.getColList("", "[COL_NAME]", ",\n\t", "", "(((INS or UPD) and !TRG) and REW)")%>,
IND_UPDATE
*<%for (int i=odiRef.getDataSetMin(); i <= odiRef.getDataSetMax(); i++){%>*
<%=odiRef.getDataSet(i, "Operator")%>
select <%=odiRef.getPop("DISTINCT_ROWS")%>
<%=odiRef.getColList(i,"", "[EXPRESSION]", ",\n\t", "", "(((INS or UPD) and !TRG) and REW)")%>,
<% if (odiRef.getDataSet(i, "HAS_JRN").equals("1")) { %>
JRN_FLAG IND_UPDATE
<%} else {%>
'I' IND_UPDATE
<%}%>
from <%=odiRef.getFrom(i)%>
where (1=1)
<%=odiRef.getJoin(i)%>
<%=odiRef.getFilter(i)%>
<%=odiRef.getJrnFilter(i)%>
<%=odiRef.getGrpBy(i)%>
<%=odiRef.getHaving(i)%>
<%}%>
]]></Field>
</Object>
<Object class="com.sunopsis.dwg.dbobj.SnpLineTrt">
<Field name="AlwaysExe" type="java.lang.String"><![CDATA[0]]></Field> -
How to export data from a Oracle table to a delimited file?
I know how to load delimited file into a table, but how to export
data from a Oracle table to a delimited file?
Thanks in advance.Try looking at this link, it's long but there's three different solutions discussed in it. If you look at Barbara Boehmer's
solution in her posts in the link below you'll see that she's addressed your concerns with spool files.
Re: utl_smtp and triggers -
Hello All,
I am trying to export data to Excel from a report output. Its a simple report. I have tried the below FM
CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
EXPORTING
DATA_FILENAME =
DATA_PATH_FLAG = 'W'
DATA_ENVIRONMENT =
DATA_TABLE =
MACRO_FILENAME =
MACRO_PATH_FLAG = 'E'
MACRO_ENVIRONMENT =
WAIT = 'X'
DELETE_FILE = 'X'
EXCEPTIONS
NO_BATCH = 1
EXCEL_NOT_INSTALLED = 2
INTERNAL_ERROR = 3
CANCELLED = 4
DOWNLOAD_ERROR = 5
NO_AUTHORITY = 6
FILE_NOT_DELETED = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
This FM when executed without passing any data is able to open an empty excel sheet but when I try to pass an internal table to DATA_TABLE its giving a dump. The run time error is CALL_FUNCTION_CONFLICT_TYPE.
Error:
**"The function module interface allows you to specify only fields
of a particular type under "TABNAME". The field "ITAB1" specified here
has a different field type."**
Please let me know if Im missing something.
Thanks in advance.Hi SAP,
Simply List -> Save -> File -> spreadsheet -> file.xls
Or check this weblog..
<a href="/people/dennis.vandenbroek/blog/2007/02/14/simple-function-module-to-export-any-internal-table-to-ms-excel:///people/dennis.vandenbroek/blog/2007/02/14/simple-function-module-to-export-any-internal-table-to-ms-excel
or
try this code..
DATA : file_name TYPE ibipparms-path,
lc_filename TYPE string.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
file_name = file_name .
lc_filename = file_name.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = lc_filename
filetype = 'DAT'
TABLES
data_tab = gt_itab.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Revert back for more help
Reward points if helpful
Regards
Naresh -
Which version of the Forms Central subscription will allow me to export data to excel (CSV file)?
Hi Heather 349
I believe you can do it with both FormsCentral Basic and FormsCentral PLUS
Also Refer : Tutorial: Exporting Responses to Excel, CSV or PDF -
Export data to excel using DOI(desktop Office integration) technique
Hi Experts,
I have the requirement to export data to excel file, I have some idea using OLE but no idea of exporting to excel using DOI, Please help me by providing sample code for it.
My requirement also include merging of cells and coloring of cells.
Thanks
RohitFor merging of cells you can refer following code!
[Merging of cells.|https://www.sdn.sap.com/irj/scn/wiki?path=/display/community/oleconceptfordownloadingthereportoutputintoexcel]
Regards,
Lalit Mohan Gupta.
Maybe you are looking for
-
I'm a new Mac Pro user. Now running OS X Lion. Always used Windows platforms before with Seagate hard drives and their included backup software where I was able to setup different backup schedules to back up various drive and file combos individual
-
HT4113 how do i unlock my sons ipod
My sons ipod is locked and he can't remember the password. i tried to sync it with the computer and it says i need the passcode which we don't have and now the ipod is disabled. Please help me how do i get this fixed???????
-
HELP me please with a basic Mac Problem
I recently updated to Yosemite, and I have a question that can hopefully be fixed. Even as I am typing, the problem is occuring. The issue is that right now, my cursor is in this little box typing, but all of a sudden, its gone. For example, when you
-
Seeking Information on PE4 Encoding and Encoders.
Hi. I have spent several hours looking at forums and manuals trying to learn how to better use my stuff. I have several questions which I have not found answers too. If some folks could help answer some or all, it would be appreciated. I have se
-
Solved :How to do this Query ??
Hello Everyone, I have a table structure like this.... Courses -- which contain the list of courses...with course_id being primary key Tasks -- which contains the list of courses...with task_id being the primary key Course History -- contains list of