Csv/excel
hello,
i have a html report
i wish to have a option that generates html
how do you do this
tips??
<cfloop query="westcoastCases">
<tr>
<td>#allcaseID#</td>
<td>#dateformat(CRTN_DT,"mm/dd/yyyy")#</td>
</tr>
</cfloop>
Hello,
could you be a bit more specific?
Do you want to generate the file in a different way or do you want to modify the file before opening it in Excel?
To generate the header into the csv you can use an example from BluShadow {message:id=9525835}, to generate formatted "Excel" files you can ask the FAQ {message:id=9360007}
Regards
Marcus
Edited by: Marwim on 18.07.2011 08:53
Addes links
Similar Messages
-
How can I create an csv/excel file using pl/sql and then sending that file
How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.968776 wrote:
How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
Whay do you want database (pl/sql) code to do these things?
Anyhow, you may be interested in :
{message:id=9360007}
{message:id=9984244} -
Csv/excel not showing vertical . it is displaying horizontally plus
hi i have this code that displays html, pdf or csv/excel
download.
htmll report and pdf is ok but the csv/excel download
displays/ works but
it shows accross instead of down.
on my html to csv it is not dispalying vertically /down and
it shows the html on the excel download
also
per cel it has both the plotid and the ceenum. it displays
horizontally.
Help
Thanks in advance.
<!-------------------- here are the code in 2 .cfm pages.
here is the first page where the user selects
html
pdf
escel/csv----------then it goes to a action page act_lop.cfm
<h1>LOP Reports </h1>
<div align="center">
<form name="theForm" action="act_lop.cfm"
method="post"><BR />
Sorted by:
<select name="Orderby" size="1">
<option value="CEEnum">CEE num</option>
<option value="Plot">plot No</option>
</select>
<br />
<br />
Output Format:
<input type="radio" name="outputFormat" value="HTML"
checked="checked" />
HTML
<input type="radio" name="outputFormat" value="PDF" />
PDF
<input type="radio" name="outputFormat" value="CSV" />
Download/Open Excel Spreadsheet <BR />
<br />
<input name="Submit" type="Submit" value="Generate Report"
/>
<BR />
<BR />
<BR />
</form>
</div>
</body>
</html>
<!--------- act_lop.cfm the action page. Html and pdf is
working ok but the problem is the excel sheet.
<cfquery name="getlop" datasource="oracdb10">
select
tabTee.CEEnum,
tabTee.Plot,
FROM
tabTee
ORDER BY
<cfswitch expression="#Form.orderBy#">
<cfcase value="CEEnum">
tabTee.CEEnum
</cfcase>
<cfcase value="Plot">
tabTee.Plot
</cfcase>
</cfswitch>
</cfquery>
<!---html report--->
<cfswitch expression="#Form.outputFormat#">
<cfcase value="HTML,PDF">
<cfsavecontent variable="htmlData">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>lop</title>
</head>
<style type="text/css">
td{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
th{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
background-color:#FFFF99;
h2{
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
h3{
font-family:Arial, Helvetica, sans-serif;
font-size:15px;
</style>
<body>
<cfoutput>
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td align="center">
<h3>lop</h3><br><br></td>
</tr>
<tr>
<td align="center">
</h2>Your report returned #getlop.RecordCount#
records</h2></td>
</tr>
<tr>
<td>
<table border="2" cellpadding="2" cellspacing="0">
<tr>
<th>Record Number</th>
<th width="120">CEE num</th>
<TH>plot No</TH>
</tr>
<cfloop query="getlop">
<tr bgcolor="<cfif currentrow mod
2>GHOSTWHITE<cfelse>WHITE</cfif>">
<td>#CurrentRow#</td>
<Td>#CEEnum#</td>
<td>#Plot#</td>
</tr>
</cfloop>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
</cfoutput>
</cfsavecontent>
<cfswitch expression="#Form.outputFormat#">
<cfcase value="HTML">
<cfoutput>
#htmldata#
</cfoutput>
</cfcase>
<cfcase value="PDF">
PDF
<cfdocument format="pdf">
<cfoutput>
#htmldata#
</cfoutput>
</cfdocument>
</cfcase>
</cfswitch>
</cfcase>
<cfcase value="CSV">
<CFHEADER NAME="Content-Disposition" VALUE="attachment;
filename=lop.csv">
<cfcontent type="application/msexcel">"Cee Num","plot
No"
<cfoutput query="getlop"> #ltrim(CeeNum)#, #PLOT#
</cfoutput>
<cfabort>
</cfcase>
</cfswitch>
<!-----------here is the las page
------------------------csv---------------------------->
<cfquery name="getlop" datasource="oracdb10">
select
tabTee.CEEnum,
tabTee.Plot,
FROM
tabTee
ORDER BY
tabTee.CEEnum
</cfquery>
<CFHEADER NAME="Content-Disposition" VALUE="attachment;
filename=lop.csv">
<cfcontent type="application/msexcel">"CEE num","plot
No"
<cfoutput query="getlop">#CEEnum#,#Plot#
</cfoutput>CSV interpreted format expects a carriage return/line feed at
the end of the row. Try
<cfcontent type="application/msexcel">
"CEE num","plot
No"<cfoutput>#chr(13)&chr(10)#</cfoutput>
<cfoutput
query="getlop">#CEEnum#,#Plot##chr(13)&chr(10)#
</cfoutput>
HTH, -
Good Morning,
I'm working with a back-up admin on setting up the CSV/Excel JDBC drivers to enable me to connect VC models to CSV/Excel data.
Can anyone provide a step-by-step (or more detailed description) for the setup steps at: <a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/jdbcConnectionSetup&.">SDN VC - JDBC Connection Setup</a>
After navigating to the described service, the admin is not sure of the next step.
Are the above steps at SDN for NW04s?
ThanksThere is a whole section in the WIKI with links to setup for different BI connectors:
https://wiki.sdn.sap.com/wiki/display/VC/Setup+connections
And yes, those are all valid for NW04s. -
Mime mapping in web.xml not working for csv/excel
I am using the weblogic 8.1 app server. I want to serve up some static content
from an "exploded" web application (dir structure instead of a war file). This
static content includes html files and csv files that cause the browser to give
an option to the user to open the file in excel or download to disk. I have inserted
the following mapping inside web.xml in the exploded directory structure...
<web-app>
<mime-mapping>
<extension>csv</extension>
<mime-type>application/vnd.ms-excel</mime-type>
</mime-mapping>
</web-app>
I redeployed the "web application". When I try to access a csv file, instead of
giving me the save/open dialog, the browser displays the ASCII contents of the
csv in the browser like an HTML file. Am I missing a step? Is the xml above not
for the functionality that I am trying to implement here?
Thanks.Hi All:
Thanks for all your help regarding the adfAuthentication success_url. Now I am able to configure to make this work. But now I am facing another issue i.e. I am getting 401 Not authorized message when the success_url is pointed to the jspx page.
Note: I am using custom login module similar to DBProcOraDataSourceLoginModule so my roles are stored in the custom Role class. So I am not sure how to pass this role info to the security in ADF in order to authorize the page to be viewed.
Could you please help and can you point me to any specific link.
Thanks & Regards
Sridhar Doki -
Import CSV/Excel data into Flex Datagrid using Java/JSP
Hi,
Is there any way we can import excel/csv data into flex datagrid component.
I see that is been done using php in this site. http://code.google.com/p/as3xls/
Any help would be appreciated.
Thanks in advanceYou can store the list of data from the Excel sheet that you have read already into an ArrayList
Then go through the JDBC tutorial, and learn how to insert a single record into the table.
After you understand how to insert a single record, you can iterate through the ArrayList of data and insert them into the table in the database.
If you know JDBC, see if you can use OR Mapping frameworks like Hibernate or iBatis, they make it very easy to manage database in Java. -
Need to upload a CSV/Excel to a table in OAF page
I have an updatable products table on a OAF page. I need to provide that table with an 'Upload' button, On clicking, user should be able to browse for the excel/csv(It contain some products) file from local desktop and be able to upload it into products table.
Any idea how this can be done?
Do we need to use messageFileUpload> get DataObject>> convert to StringBuffer>>> and break it into rows >>>>insert each row thru VO >>>>> refresh the VO?
Is that the process or do we have any other process. If so could you please point out to some examples of using messageFileUpload?
Thanks,
Santosh.public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = (OAApplicationModule) pageContext.getApplicationModule(webBean);
OAViewObjectImpl vo = (OAViewObjectImpl) am.findViewObject("XxCholaCsvDemoVO1");
if ("Go".equals(pageContext.getParameter(EVENT_PARAM)))
DataObject fileUploadData =(DataObject)pageContext.getNamedDataObject("FileUploadItem");
String fileName = null;
String contentType = null;
Long fileSize = null;
Integer fileType = new Integer(6);
BlobDomain uploadedByteStream = null;
BufferedReader in = null;
try
fileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
contentType =(String)fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, fileName);
in = new BufferedReader(new InputStreamReader(uploadedByteStream.getBinaryStream()));
fileSize = new Long(uploadedByteStream.getLength());
System.out.println("fileSize"+fileSize);
catch(NullPointerException ex)
throw new OAException("Please Select a File to Upload", OAException.ERROR);
try{
//Open the CSV file for reading
String lineReader="";
long t =0;
String[] linetext;
while (((lineReader = in.readLine()) !=null) ){
//Split the deliminated data and
if (lineReader.trim().length()>0)
System.out.println("lineReader"+lineReader.length());
linetext = lineReader.split(",");
t++;
//Print the current line being
System.out.println(t + " - " +
linetext[0].trim() + " - " + linetext[1].trim() + " - " +
linetext[2].trim() + " - " + linetext[3].trim() + " - " +
linetext[4].trim() + " - " + linetext[5].trim() );
if (!vo.isPreparedForExecution()) {
vo.setMaxFetchSize(0);
vo.executeQuery();
Row row = vo.createRow();
row.setAttribute("Column1", linetext[0].trim());
row.setAttribute("Column2",linetext[1].trim());
row.setAttribute("Column3",linetext[2].trim());
row.setAttribute("Column4", linetext[3].trim());
vo.last();
vo.next();
vo.insertRow(row);
catch (IOException e)
throw new OAException(e.getMessage,OAException.ERROR);
else if ("Upload".equals(pageContext.getParameter(EVENT_PARAM))) {
am.getTransaction().commit();
throw new OAException("Uploaded SuccessFully",OAException.CONFIRMATION);
} -
Hi,
I have a search result which has some date columns and have a button to export these results to CSV file.
The database column is of datatype VARCHAR but date is stored in it and displayed, so while fetching data from there we are converting it to date in format DD-MON-YYYY.
while displaying the search results, its working perfectly fine.
When downloaded to CSV file, and Opened with Any Text Editor other than Excel, the date format is proper as in screen ie. DD-MON-YYYY
But, once we open the CSV in excel update few columns and save the file, the date gets saved in the DD-MON-YY format.
Since this file will be uploaded back to the application, we can either design our recieving application to expect date in DD-MON-YY format. But is there anything that we can do to have it maintained in DD-MON-YYYY format itself ?Can any one please help me out. Iam in need of a labview code which has a excel sheet consists of
3 columns
1) DATE
2) TIME
3) TEMPERATURE value.
If a string is entered as a input and that string should be compared with the Names under DATE AND TIME column in the excel sheet and if the string entered matches with any of the string under the DATE AND TIME column then it should pass one output
1) The value of that string
For example if Iam entering the i/p as 10/7/2012 03:55:05 PM then it should search the strings under DATE AND TIME tab and if row 8 as the 10/7/2012 03:55:05 PM string with a value of 461.106 then it should return two o/p's one as 461.106
If the entered string is not matched with any of the strings under DATE AND TIME coulmn it should return an output as zero.
i am attaching a excel sheet screen shot which is in csv format
Thank You
Attachments:
excel in csv.docx 190 KB -
Wrong output in excel CSV - Excel displayes more records as the report
Hello,
I have a report with a parameteritem : p1_date_ from that will be filled by
Source value or expression
select to_DATE ('12/MAY/2005','DD/MON/YYYY') from dual
The report query used this Parameter in the query: SELECT * FROM .. WHERE ( TRUNC (at.my_date) >= :p1_date_from
OR :p1_date_from IS NULL)..
Run the application -> only one record comes back, but
If you click on the excel export and show the file two records will be displayed
It looks like that the excel link will not use the parameter p1_date_form
after pressing a button Go with (go_submit) -> Excel will display only 1 record -> correctly.
This looks like default behaviour, but the problem is how to "synchronize" both the Report and the CSV export?
I received an idea from Scott Spadafore, but the implemetation doesn't work as expected.
If needed I have a short testcase tablecreate script, table insert script and application export .I tested the testcase in htmldb.oracle.com and it was not longer reproduceable, but my customer needs a workaround for version 1.6
THe question is : How to get a javascript onchange event to fire and submit the page so that the values would be in session state. -
Csv excel problems line breaks
hello there, i am new to cf but i have this report that has a
csv option for excel.
but the problem is :
it has breaks between cells.
meaining:
there are rows/records that ar empty
for example:
row 1 is filled with columns.
then
empty row
empty row
then,
row 3 is filled with columns.
any ideas?You shouldn't have to do anything special in HTMLDB to export data with LF in the text.
Build your region based on a SQL statement ie:
Select ID, title, subtitle from document
On the report attributes page set CSV Output to YES and add a label for the url.
When you click the CSV url you should get output that looks like this:
"ID","TITLE","SUBTITLE"
"1","My Title","My subtitle
has a line break"
"2","Title2","My subtitle2"
Excel or Word should be able to read this file just fine.
I set up a test at:
http://www.mydataexpert.us:7777/pls/htmldb/f?p=132:8000
Michael
I. Michael Snyder
Vice President
CASEtech, Inc
202-423-4499 (c)
[email protected]
------------------------------ -
Import CSV Excel into Access - Missing Data
I am saving a file in Excel as a .CSV. When I import it into my Access database, some of the data is missing
Please see this.
http://www.accessmvp.com/KDSnell/EXCEL_Import.htm
Instead of Excel, use CSV, like this.
DoCmd.TransferText acImportDelim, "ImportSpecificationName",
"TableName", "C:\yourCsv.csv", True
Finally . . .
http://databasesuperstar.com/ms-access-tutorial-how-to-import-csv-file/
https://support.office.com/client/Import-data-into-an-Access-database-782703aa-6b21-4458-9429-480eaf0c71d6
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
Not able to generate output in CSV(EXCEL) format
Hi,
XML Publisher report is giving me an error when the Preview Format is 'EXCEL'. When I keep the Preview Format as 'PDF', the concurrent program is running successfully and the PDF output is getting generated. But for EXCEL outputs, I am getting the following error :
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
The operation completed successfully. Error processing resource 'http://erpap01:8010/OA_CGI/FNDWRR.exe?temp_id=1...
<td valign="top" class="c7"><p class="c8"><span class="c9">13 July 2009 13:15:57 PM</span>...
I have using the following Data Template for Data Definition
<?xml version="1.0" encoding="UTF-8"?>
<dataTemplate name="EMPDT" description="Employee Details" version="1.0">
<parameters>
<parameter dataType="character" name="p_DeptNo"> </parameter>
</parameters>
<dataQuery>
<sqlStatement name="Q1">
<![CDATA[SELECT EMPNO
,ENAME
,JOB
,MGR
,HIREDATE
,DEPTNO
,SAL
,COMM
FROM scott.Emp
WHERE deptno = NVL(:p_DeptNo,deptno)
]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_EMP" dataType="varchar2" source="Q1">
<element name="EMPNO" value="EMPNO"/>
<element name="ENAME" value="ENAME"/>
<element name="JOB" value="JOB"/>
<element name="MGR" value="MGR"/>
<element name="HIREDATE" value="HIREDATE"/>
<element name="DEPTNO" value="DEPTNO"/>
<element name="SAL" value="SAL"/>
<element name="COMM" value="COMM"/>
</group>
</dataStructure>
</dataTemplate>
When I click on Diagnostic - View XML, copy the XML file and generate report using Word plugin, I am able to generate output in PDF and in EXCEL. But for some reason, when I try to run the XML Publisher report using concurrent program, I am unable to generate output in EXCEL and I am getting the error as listed above.
When I click on View Template - Preview, keeping the Preview format as Excel, I get the following error :
Exception Detail
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor179.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at oracle.apps.xdo.common.xml.XSLT10gR1.invokeParse(XSLT10gR1.java:517)
at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:224)
at oracle.apps.xdo.common.xml.XSLTWrapper.transform(XSLTWrapper.java:177)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1044)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:997)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:212)
at oracle.apps.xdo.template.FOProcessor.createFO(FOProcessor.java:1657)
at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:967)
at oracle.apps.xdo.oa.schema.server.TemplateHelper.runProcessTemplate(TemplateHelper.java:5888)
at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3438)
at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3527)
at oracle.apps.xdo.oa.template.server.TemplatesAMImpl.processTemplate(TemplatesAMImpl.java:2130)
at sun.reflect.GeneratedMethodAccessor173.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:190)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:153)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:749)
at oracle.apps.xdo.oa.template.webui.TemplateGeneralCO.previewTemplate(TemplateGeneralCO.java:741)
at oracle.apps.xdo.oa.template.webui.TemplateGeneralCO.processRequest(TemplateGeneralCO.java:158)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:587)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1136)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2335)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1734)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:508)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:429)
at oa_html._OA._jspService(_OA.java:85)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
at oracle.jsp.JspServlet.service(JspServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at oracle.jsp.provider.Jsp20RequestDispatcher.forward(Jsp20RequestDispatcher.java:162)
at oracle.jsp.runtime.OraclePageContext.forward(OraclePageContext.java:187)
at oa_html._OA._jspService(_OA.java:95)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
at oracle.jsp.JspServlet.service(JspServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
at org.apache.jserv.JServConnection.run(JServConnection.java:294)
at java.lang.Thread.run(Thread.java:534)
Caused by: oracle.xdo.parser.v2.XMLParseException: Start of root element expected.
at oracle.xdo.parser.v2.XMLError.flushErrors1(XMLError.java:324)
at oracle.xdo.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:319)
at oracle.xdo.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:281)
at oracle.xdo.parser.v2.XMLParser.parse(XMLParser.java:266)
Any inputs would be appreciated
Regards
DavidMay be it is browser problem? use another browser like Firefox
Edited by: ranalawa on Jul 14, 2009 2:21 PM -
How to download a csv/excel file stored in a server using OA Framwork
Hi All,
We have a requirement where we have to generate a CSV file using PL/SQL block and the user shoul download that csv file to his client machine whenever it requirs to him. We have generated csv file and save the same in a particular location in the server. As the CSV file size may be around 10 to 15 MB we feel the storing and retrieving of the csv file in a BLOB object is a performance hit. Now we want to dowload the file from the csv file path without storing the csv file into database BLOB object.
Is this possible using OA framwork? if so please guide me how to do this.
Thanks in advance.
Regards,
Sathesh.If u know following details you can use below method to download any file ( XLS/any) its generic method I have used in one of my project-
1. File Name with Extension
2. File path at which it has been placed
3. Page Context (you must know i assume)
public void DownloadFileFromServer(OAPageContext pgeContext, String file_name_with_path,
String file_name_with_ext)
System.out.println("Filename path "+file_name_with_path + "File Name:" + file_name_with_ext);
HttpServletResponse responseVar = (HttpServletResponse)pageContext.getRenderingContext().getServletResponse();
if (((file_name_with_path == null) || ("".equals(file_name_with_path))))
System.out.println("File path is invalid.");
File fileToDwnld = null;
try
fileToDwnld = new File(file_name_with_path);
catch (Exception e)
System.out.println("Invalid File Path or file does not exist.");
if (!fileToDwnld.exists())
System.out.println("File does not exist.");
if (!fileToDwnld.canRead())
System.out.println("Not Able to read the file.");
String MADfileType = getMADMimeType(file_name_with_ext);
System.out.println("File Type - " + MADfileType);
responseVar.setContentType(MADfileType);
responseVar.setContentLength((int)fileToDwnld.length());
System.out.println("File Size is " + fileToDwnld.length());
responseVar.setHeader("Content-Disposition", "attachment; filename=\"" + file_name_with_ext + "\"");
InputStream inStr = null;
ServletOutputStream outStr = null;
try
outStr = responseVar.getOutputStream();
inStr = new BufferedInputStream(new FileInputStream(fileToDwnld));
int ch;
while ((ch = inStr.read()) != -1)
outStr.write(ch);
catch (IOException e)
e.printStackTrace();
finally
try
outStr.flush();
outStr.close();
if (inStr != null)
inStr.close();
catch (Exception e)
e.printStackTrace();
Edited by: aprak on Oct 18, 2011 1:08 AM
Edited by: aprak on Oct 18, 2011 1:09 AM -
How to delete 1st 2 rows in a csv/excel file?
Hi,
Is there a way to read a csv file and delete the 1st 2 rows (or any no. of rows I would like to)?
I'm currently using Ben Nadel's GREAT piece of code (Parsing CSV Values into a Coldfusion query) found at http://www.bennadel.com/index.cfm?dax=blog:501.view as follows:
<!--- Read file --->
<cffile action="read" file="#variables.uploadedFile#" variable="csvResult">
<!--- Invoke method to convert csv data to query --->
<cfinvoke component="components.csvToQuery" method="CSVToQuery" returnvariable="qCsvData">
<cfinvokeargument name="CSV" value="#trim(variables.csvResult)#">
<cfinvokeargument name="FirstRowIsHeadings" value="true">
</cfinvoke>
I need to manipulate qCsvData to delete the 1st 2 rows.
Any ideas would be most welcome.
Thanks and regards,
Yogesh MahadnacHi Joseph,
Thanks again for your brilliant answer!
I still need you help by the way, if you don't mind, of course!
I've based myself on your logic and tried to implement it differently.
(apologies if it's a bit complicated. it's almost 1 o'clock in the morning here, and sleep is getting over...)
Here is what I've done:
Now, I know that I need to ignore the 1st 2 rows, which means, my headers in fact start on the 3rd row.
I've created my column names dynamically and then added rows to my query object.
<cffunction name="removeRecords" returntype="Query" output="false" description="I remove records from a query.">
<cfargument name="queryObject" type="Query" required="true" hint="Query to remove records from" />
<!--- Initialise function local variables --->
<cfset var myQry = QueryNew("")>
<cfset var i = 0>
<cfset var j = 0>
<cfset var columnName = "">
<cfset var columnList = "">
<cfset var tempList = arguments.queryObject.columnList>
<!--- Loop query --->
<cfloop index="i" from="1" to="#arguments.queryObject.recordcount#">
<!--- Ignore 1st 2 rows, 3rd row is header --->
<cfif i gt 2>
<cfif i eq 3><!--- Create headers --->
<!--- Loop column list (column_1, column_10, ...) --->
<cfloop index="j" from="1" to="#listLen(tempList)#">
<cfset item = ListGetAt(tempList,j)>
<!--- Remove blank spaces --->
<cfset columnName = replaceNoCase(trim(arguments.queryObject[item][i])," ","_","All")>
<!--- Remove slash --->
<cfset columnName = replaceNoCase(trim(columnName),"/","_","All")>
<!--- Create column name --->
<cfset QueryAddColumn(myQry,columnName,"cf_sql_varchar",ArrayNew(1))>
<!--- Create list of column names --->
<cfset columnList = columnList & columnName & ",">
</cfloop>
<!--- Remove trailing comma --->
<cfset columnList = left(columnList,len(columnList)-1)>
<cfelse><!--- As from 4th row, we add 1 new row to myQry for each iteration --->
<!--- Add rows --->
<cfset QueryAddRow(myQry)>
<cfloop index="j" from="1" to="#listLen(tempList)#">
<cfset item = ListGetAt(tempList,j)>
<cfset fieldValue = trim(arguments.queryObject[item][i])>
<cfset col = listGetAt(columnList,j)>
<cfset QuerySetCell(myQry,col,fieldValue)>
</cfloop>
</cfif>
</cfif>
</cfloop>
<cfreturn myQry>
</cffunction>
Question:
Is there a simpler way to do the following?
<cfset columnName = replaceNoCase(trim(arguments.queryObject[item][i])," ","_","All")>
<cfset columnName = replaceNoCase(trim(columnName),"/","_","All")>
I'm trying to replace all blank spaces and any "/" between words with an "_".
I know we can use Regular Expressions to do it much simpler, but I'm not very familiar with the syntax.
I'd be grateful if you could please provide me with the correct syntax.
Thanks in advance.
Best regards,
Yogesh -
How to convert org hierarchy XML to CSV/Excel format using PI/XI
Hi All,
I am working with SAP PI/XI for the first time and need some help file conversion of complex hierarchy XML to CSV file using PI. I have done plenty of research on SDN and could find much related to what I want to do.
Here is the example of how my input XML would look like:
<?xml version="1.0" encoding="UTF-8"?>
<PartyMaster type="OrgHierarchy" name="Compass Group Owned">
<PartyMasterHierarchy>
<Hierarchy level="3" nodeName="Bon Appetit Sector" type="Sector" ID="A00000" refID="A00000">
<Hierarchy level="4" nodeName="BA Division" type="Division" ID="AB0000" refID="AB0000" >
<Hierarchy level="5" nodeName="BA East Coast Region" type="Region" ID="ABE000" refID="ABE000">
<Hierarchy level="6" nodeName="Engstrom, John RVP" type="District" ID="ABE01" refID="ABE01" >
</Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
<Hierarchy level="3" nodeName="Levy Sector" type="Sector" ID="K00000" refID="K00000".
<Hierarchy level="4" nodeName="Levy Sector Division" type="Division" ID="K90000" refID="K90000">
<Hierarchy level="5" nodeName="Levy Sector Region" type="Region" ID="K99000" refID="K99000">
<Hierarchy level="6" nodeName="TBA Total" type="District" ID="K9901" refID="K9901"> </Hierarchy>
</Hierarchy>
</Hierarchy>
</Hierarchy>
</PartyMasterHierarchy>
</PartyMaster>
I would like to get CSV output in the format below
DISPLAY_NAME, DOCUMENT_DESCRIPTION, PARENT, EXTERNAL_ID, ORG_UNIT_TYPE
Bon Appetit Sector, Bon Appetit Sector,constant value, A00000, constant value
Levy Sector, Levy Sector, constant value, K00000, constant value
BA Division, BA Division, A00000, AB0000, constant value
Levy Sector Division, Levy Sector Division, K00000, K90000, constant value
BA East Coast Region, BA East Coast Region, AB0000, ABE000, constant value
Levy Sector Region, Levy Sector Region, K90000, K99000, constant value
Engstrom John RVP, Engstrom John RVP, ABE000, ABE01, constant value
TBA Total ,TBA Total ,K99000, K9901, constant value
1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
Any help will be greatly appreciated.
Thanks.
--Mithun>>> 1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
Use File adapter at the sender side to pick up the xml and use file adapter at the receiver side (message protocol file content conversion) to convert xml format to csv.
Basically you have to configure in the file adapter (FCC) on the receiver side to get desired csv structure from XML.
>>> 2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
Configure sender file adapter to pick up the file from the specified directory. Configure receiver file (fcc adapter) to drop the csv file after conversion.
For sender adapter
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
For receiver adapter in our case FCC (FILE content Conversion) follow the link
http://help.sap.com/saphelp_NW04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
Hope answered your question.
Mapping area: simple suggestion. Keep input and output message same structure and do one to one mapping. In the receiver fcc adapter configure for csv structure following instruction given in the above second link
Note: FCC adapter does not support nested structure more than 2. So in your case you can achieve using conversion agent tool. Otherwise you might have to achieve through some graphical mapping.
Maybe you are looking for
-
Hi gurus, Doing reserch for a report of Sales by SKU for a particular Material no. Need help in understanding how to get 1. Report or data in ECC for this SKU 2. Datasouces, tables and fields required to create a report in BI for this SKU. The report
-
Dear Friends While I was trying to create a Business Event in PSV2, sys showing a msg like Planning period is not in business event interval while creating without resources But for the same for the same period if I try to create with resources its
-
How to run *.class in JSP. For example, the demo class, Clock.class is run in html format, Can I run the Clock.class in JSP format?
-
What data sources are being used
Hi, I am about to create a new Planning application (v9.3.1.1) and we currently have two other Planning applications. When I select Create Application from the administration menu, I can see one Data Source available in the listbox. Does that mean th
-
Why does my ipod touch 4th gen battery life drain so quick
I've had my iPod touch for a few years now, but recently The battery life drains very fast, even if I go on one app it goes down half way after charging it full, I don't know why? My iPod will last me 30-1hour, is there a way of fixing this? :-)