Problem delivering XLS File
Hi
In my application, i have a module that has to deliver a XLS file, that was previously uploaded.
This is the code i am using for it:
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
String filePath = "thePhisicalPathToTheXLSFile.xls"
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
response.setContentType("application/vnd.ms-excel");
outputStream = response.getOutputStream();
FileInputStream fis = new FileInputStream(filePath);
bis = new BufferedInputStream(fis);
bos = new BufferedOutputStream(outputStream);
byte[] buff = new byte[2048];
int bytesRead;
// Simple read/write loop.
while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (outputStream != null);
outputStream.close();
if (bis != null)
bis.close();
if (bos != null)
bos.close();
} catch (Exception e) {
//ignore
The file is delivered, but something happens in the process that makes the file unable to be read; excel always shows me a warning that the file is damaged and cannot be read
What can be happening ???
Thanks
is the downloaded file size the same as the original? have you tried opening the downloaded file with a text editor?
Similar Messages
-
Problem reading .xls file from App Server
Hi Everyone......
I hope this might be a common problem but i searched for similar problem......i did'nt find the solution my problem is
I'm trying to download .xls(excel file data into an internal table using OPEN DATASET FOR INPUT IN TEXT MODE ENCODING DEFUALT and read dataset for reading it).But in the read dataset syntax all stange values like **$#@&&& are getting uploaded???? I dont now why......
Is it happing because i'm trying to upload .XLS file ???
My coding is as follows...........
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
IF sy-batch IS INITIAL.
MESSAGE i001(zz) WITH 'Error opening file for upload'.
EXIT.
ELSE.
MESSAGE s001(zz) WITH 'Error opening file for upload'.
EXIT.
ENDIF.
ENDIF.
*First Uploading the data into structure
DO.
READ DATASET p_file INTO l_wa_tab. "My internal table work area
IF sy-subrc = 0.
APPEND l_wa_tab TO l_tab.
ELSE.
EXIT.
ENDIF.
ADD 1 TO count.
ENDDO.
CLOSE DATASET p_file.
Any solution for above problem.........Hi,
Check whether path ur providing to the open data set stmt is correct or not in debugging mode.
* File upload to internal table from UNIX Directory
IF NOT p_i1file IS INITIAL AND NOT p_path IS INITIAL.
CONCATENATE p_path p_i1file INTO v_file.
CONDENSE v_file.
OPEN DATASET v_file FOR INPUT IN TEXT MODE MESSAGE v_msg.
IF sy-subrc EQ 0.
WRITE: / 'INPUT FILE CONTAINS NO RECORD :'(010), v_file.
DO.
CLEAR tbl_input.
READ DATASET v_file INTO tbl_input.
IF sy-subrc NE 0.
EXIT.
ELSE.
APPEND tbl_input.
ENDIF.
ENDDO.
* Close Input File
CLOSE DATASET v_file.
ELSE.
WRITE:/'Error uploading file: '(008),v_file.
STOP.
ENDIF.
ENDIF.
It should work.check the sy-subrc value and file value in debug mode.
Thanks
Parvathi -
Problem sending xls file in an attachment via ABAP proxy
Hello,
I have in tmp directory a xls file, I tranfer such file to a table, and afterwards I send in an attachment via ABAP proxy, here is the code:
l_attachment TYPE REF TO if_ai_attachment,
lt_attach TYPE prx_attach,
l_name TYPE string,
lx_string TYPE xstring,
l_string TYPE string,
l_type TYPE string,
des TYPE string.
CLASS cl_ai_factory DEFINITION LOAD.
DATA: BEGIN OF itab OCCURS 0,
raw(255) TYPE x,
END OF itab.
DATA: l_controller TYPE REF TO if_ai_posting_controller.
DATA: it TYPE zhcm_mt_segur_out.
CREATE OBJECT prxy.
OPEN DATASET orig FOR INPUT IN binary MODE.
READ DATASET orig INTO itab-raw.
WHILE sy-subrc = 0.
APPEND itab.
READ DATASET orig INTO itab-raw.
ENDWHILE.
CLOSE DATASET orig.
LOOP AT itab.
CONCATENATE lx_string itab-raw INTO lx_string in byte mode.
ENDLOOP.
L_NAME = 'Segur.xls'.
L_TYPE = CL_AI_ATTACHMENT=>IF_AI_ATTACHMENT~C_MIMETYPE_EXCEL.
TRY.
L_ATTACHMENT =
CL_AI_FACTORY=>CREATE_ATTACHMENT_FROM_binary(
P_DATA = LX_STRING
P_TYPE = L_TYPE
P_NAME = L_NAME ).
APPEND L_ATTACHMENT TO LT_ATTACH.
L_CONTROLLER = CL_AI_FACTORY=>CREATE_CONTROLLER( ).
L_CONTROLLER->SET_ATTACHMENTS( LT_ATTACH ).
CALL METHOD PRXY->EXECUTE_ASYNCHRONOUS
EXPORTING
CONTROLLER = L_CONTROLLER
OUTPUT = IT.
COMMIT WORK.
CATCH CX_AI_SYSTEM_FAULT .
DATA FAULT TYPE REF TO CX_AI_SYSTEM_FAULT .
CREATE OBJECT FAULT.
WRITE :/ FAULT->ERRORTEXT.
ENDTRY.
I am using a Mail receiver channel, I receive a mail, with to attachments, one .xml and the other one .bin, I save it to my computer and I change the extension to .xls and when I try to open it, the file is not valid and can be opened after being repaired. What Im doing wrong? I would like to receive a valid xls file, what i should change?
Thanks a lot,
LuisHi,
yes I know, I have used the MessageTransformBean module, and the PayloadSwapBean module. But which parameter I should use for leaving only one attachement in the e-mail. I did this configuration:
1
localejbs/AF_Modules/MessageTransformBean
Local Enterprise Bean
<b>trans</b>
2
localejbs/AF_Modules/PayloadSwapBean
Local Enterprise Bean
<b>swap</b>
3
localejbs/AF_Modules/MessageTransformBean
Local Enterprise Bean
<b>trans1</b>
4
localejbs/sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean
Local Enterprise Bean
mail
<i><b>Module configuration</b></i>
trans
Transform.ContentDisposition
inline
swap
swap.keyName
payload-name
swap
swap.keyValue
Segur
trans1
Transform.ContentDescription
Segur
trans1
Transform.ContentDisposition
attachment;filename="Segur.xls"
trans1
Transform.ContentType
application/vnd.ms-excel;name="Segur.xls"
In the e-mail I get one attachement without name .xml and another one Segur.xsl, and I want only one attachment, the last one. What I should change in my configuration??
Best regards,
Luis -
Problem opening xls. files
I take an online college course and have recently found that when people attach xls. files I can't read them as an octet file comes up which I can't open. I have Office 2007 which has xlsx files for excel.
What is weird is that if I go into my account via explorer instead of mozilla I can open the file. The only thing I can think of is that it is a glitch of the current update.
Please help, I don't want to have to log on to explorer everytime I want to open a 2003 version of excel.I have I-work 09 [Pages 4.0 (727)]
This is the same version I had before (I think) -- At the Apple Store they used a new I-Work disc to install it onto the new hard drive.
I hope someone can help with this!
Thank you! -
Problem downloading .xls file
Hi All,
Im getting problem when trying to export a spread sheet. Initially teh filename was hardcoded and so it was working fine in IE. The code then was
response.setHeader("Content-disposition", "attachment; filename=Details.xls");
outStream.write(Results.toString().getBytes());
outStream.close();
later the reqmt changed to some new naming conventions for the file and so i modified the code like
SimpleDateFormat formatter = new SimpleDateFormat ("MM/dd/yyyy HH:mm:ss");
java.util.Date currentDate = new java.util.Date();
String dateString = formatter.format(currentDate);
String fileName = dateString+".xls";
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment; filename="+fileName);
the problem im facing now is the in the pop up for download the file name is my servlet name appended with some unknown string which includes numbers and characters. the file type shown is html.If you click save open then a new html page is been displayed with all the values.
Please help me with this issue.
Thanks
NoufalThank you so much Shanu. Its working now. It was my carelesness or rather my ignorance which caused this prob.
But Im still having a query, the excel sheet is having a [1] appended to the file name for ex 19-Jun-2006 06-46-05[1] and the client is not happy with that.
What is the reason for that square bracket and is there any way we can cut that off? your help will be greatly appreciated.
Thanks
Noufal -
Problem Delivering Project Files to Client
Anytime I back up my project files for this particular DVD it cannot be opened on another computer. I've burned the project file, all media, all menu graphics, and the .txt files for the subtitles on to a DVD. When another computer besides the one the DVD was authored on tries to open the project it gets stuck on "Loading Tracks."
What could this be?
Every so often I am also unable to open the file, and I think its getting corrupted somehow. Please help.
EDIT: I realize I forgot to delete the PAR and MPEG folders that DVD SP creates and also burned those onto the client's DVD. Would this contribute to them not being able to open it?Thanks for replying Aldershot. I am running OS 10.4.3, DVD SP 4.0.2 with 2.5 GB RAM on a Dual 2.0 G5. The project has been saved on external firewire (with ~15 GB free) as well as a duplicate on the system drive (~85 GB free). None of them open after I save it and quit. During save I get the beach ball, but eventually it comes back to normal and I can use the app as normal.
I have read that there may be an issue with the ObjectDataB file (found within the project package Contents folder). See the link below for a description of this diagnosis.
http://www.dmnforums.com/cgi-bin/readwholethread.fcgi?forum=astarte_dvd&post=041 004175700.htm&toppostid=3523
Here's some more info if you think it will help you diagnose. I got a project file and associated media on a data DVD-R to start with. Moved everything to my External drive and made numerous changes to the project file. Saved a copy with a new file name. There are 2 tracks (one 6 mins, the other 30 mins), and they each have 16 subtitle tracks. This is honestly where I think the problem lies, but I don't understand why DVDSP can't handle that many tracks. I notice it takes longer to save as I progressively import the subtitles.
If I may work with you over e-mail it would be great. Check soon.... Thanks again! -
How do I open an encrypted xls-file?
I have a sudden problem with xls-files that just started to bather me. I have used iWorks and Numbers for 5 years now and this is the first time I have faced problems with xls-files. Let me explain. On my work iMac I try to open a saved xls-file ( that I have received via e-mail and saved on my hard drive ). When opening it, the following text appear: " The file is encrypted and cannot be opened ". This occur with all xls-files - not just one. Have I done something to the preferences or ....
What should I do ?Same problem here, but file author says not encrypted, but does contain locked cells.
Could be Numbers can't read locked cells? -
Problem of Delete and Overwrite XLS file on Application Server
Hi Experts,
I want to transfer file on application server using below code and try to delete after successfully transfer on application file to other location.
I have problem during deleting file and overwrite file.
DATA: G_S_FILE TYPE EPSFILNAM,
G_S_DIR TYPE EPSDIRNAM,
G_T_FILE TYPE EPSFILNAM,
G_T_DIR TYPE EPSDIRNAM.
DATA : DELFILE(60).
G_S_FILE = '1400000051.XLS'.
G_S_DIR = '\\Dev\PO\'.
G_T_FILE = '1400000051.XLS'.
G_T_DIR = '\\Dev\PO\bkup'.
DELFILE = '\\Dev\PO\1400000051.XLS'.
CALL METHOD CL_CTS_LANGUAGE_FILE_IO=>COPY_FILES_LOCAL
EXPORTING
IM_SOURCE_FILE = G_S_FILE
IM_SOURCE_DIRECTORY = G_S_DIR
IM_TARGET_FILE = G_T_FILE
IM_TARGET_DIRECTORY = G_T_DIR
IM_OVERWRITE_MODE = 'S'
EXCEPTIONS
OPEN_INPUT_FILE_FAILED = 1
OPEN_OUTPUT_FILE_FAILED = 2
WRITE_BLOCK_FAILED = 3
READ_BLOCK_FAILED = 4
CLOSE_OUTPUT_FILE_FAILED = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
OPEN DATASET DELFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DELETE DATASET DELFILE.
ELSE.
WRITE / 'File not found'.
ENDIF.
Thanks,
Himanshu Patel.Write a Java program using Apache POI that reads in a tab delimited file and outputs an xls file (in what they call Horrible Spread Sheet Format. Create your tab delimited file and then run your Java program using appropriate OS commands.
Jelena Perfiljeva wrote:
In all honesty, I find it hard to believe other application can't accept any other format. It's actually seems rather unreasonable to expect an ERP system to create a file in an outdated format of a desktop software. Even Excel itself can open many formats, so this just doesn't make any sense.
This.
Unless you can explain exactly why the destination must be xls and no other format is acceptable, I'm going to close the thread. What is this third party tool? Why can it only read the obsolete xls file format.
I'm going through this thread and rejecting all the responses that attempt a solution that isn't xls.
I'm surprised that the OP thought that simply saving with an xls file extension would cause some magic to happen and produce an actual Excel file. -
Problem file xls with jasper (source code mixed in the content XLS file)
i´m writing xls file with jasper, the problem is that is mixed the source code of the JSP (where doing request) in the content of the file xls, do not import the API thah use.
The java code whit JASPER is like:
FacesContext ctx = FacesContext.getCurrentInstance();
ExternalContext ectx = ctx.getExternalContext();
JRDataSource dataSource = ......
InputStream inputStream = ectx.getResourceAsStream(parametro);
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(inputStream);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,new HashMap(), dataSource);
JRXlsExporter exporter = new JRXlsExporter();
ByteArrayOutputStream xlsReport = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, xlsReport);
exporter.exportReport();
byte[] bytes2 = xlsReport.toByteArray();
response.setContentType("application/vnd.ms-excel");
response.setContentLength(bytes2.length);
response.setHeader("Content-disposition", "attachment; filename="" + "MI_EXCEL_JR" + ".xls"");
ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(bytes2, 0, bytes2.length);
outputStream.flush();
outputStream.close(); whay is printed the response in the xml file?
tnk for your help....hoham wrote:
byte[] bytes2 = xlsReport.toByteArray();
Not related to the actual problem, but this line is not very efficient. What if the report is bigger than the available server memory? Or if there are many simultaneous requests which does all the same?
It would result in an OutOfMemoryError. Rather obtain it as an InputStream and write it in a loop to the OutputStream using a byte block as buffer. Or wrap the both streams by BufferedInputStream/BufferedOutputStream and write in a simple loop. Consult the basic Java IO tutorials for details and code examples. -
Problem downloading .doc, .xls file using servlet
i have a servlet which downloads the files to client(browser). It works file for .txt file but .doc, .xls files are opend but they contain garbage.
plz letr me know if u know problem!!!!!
-amitProbably because you output them using the Writer you got from getWriter instead of using the OutputStream you can get from getOutputStream.
-
Problem in attaching XLS file to decision step
Hi All,
I have a requirement where i have to add a attachment to workflow while triggering the workflow itself and attach that to user decisition step, i have searched the forum for the same and i got some piece of code which i mention here.
include <CNTN01>.
DATA: attach TYPE swc_object.
DATA:it_objhex TYPE solix_tab.
DATA:container TYPE SWCONT OCCURS 0 WITH HEADER LINE,
SIMPLE_CONTAINER TYPE STANDARD TABLE OF SWR_CONT
WITH HEADER LINE.
DATA :ml TYPE STANDARD TABLE OF swr_messag ,
ms TYPE STANDARD TABLE OF swr_mstruc ,
rc LIKE sy-subrc,
wi LIKE swr_struct-workitemid.
swc_container l_cont.
DATA folder_id TYPE sofdk.
DATA lt_objcont TYPE STANDARD TABLE OF soli.
DATA ls_objcont TYPE soli.
DATA l_obj_data TYPE sood1.
DATA l_obj_id TYPE soodk.
DATA document_id TYPE sofmk.
DATA lt_objhead TYPE STANDARD TABLE OF soli.
data wa_soli type soli.
data wa_solix type solix.
data lt_solix type STANDARD TABLE OF solix .
FIELD-SYMBOLS: <ptr_text> type soli,
<ptr_x> type any,
<ptr_hex> type solix.
define hex_to_cont.
&1 Table of structure SOLIX
&2 Table of structure SOLI
refresh &2.
loop at &1 into wa_solix.
clear wa_soli.
assign wa_soli to <ptr_hex> casting.
move wa_solix to <ptr_hex>.
append wa_soli to &2.
endloop.
end-of-definition.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETER f_n TYPE string.
SELECTION-SCREEN END OF BLOCK b1.
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
region = 'B'
IMPORTING
folder_id = folder_id
EXCEPTIONS
OTHERS = 1.
*get the XLS file into a table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = f_n
FILETYPE = 'BIN'
tables
data_tab = lt_solix
IF sy-subrc <> 0.
ENDIF.
l_obj_data-objnam = 'SOFM'.
l_obj_data-objdes = 'test'.
l_obj_data-file_ext = 'PDF'.
hex_to_cont lt_solix LT_OBJCONT.
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
folder_id = folder_id
object_type = 'EXT' "'RAW'
object_hd_change = l_obj_data
IMPORTING
object_id = l_obj_id
TABLES
objhead = lt_objhead
objcont = LT_OBJCONT
EXCEPTIONS
active_user_not_exist = 35
folder_not_exist = 6
object_type_not_exist = 17
owner_not_exist = 22
parameter_error = 23
OTHERS = 1000.
COMMIT WORK.
Data: tb_key(100).
IF sy-subrc = 0.
document_id-foltp = folder_id-foltp.
document_id-folyr = folder_id-folyr.
document_id-folno = folder_id-folno.
document_id-doctp = l_obj_id-objtp.
document_id-docyr = l_obj_id-objyr.
document_id-docno = l_obj_id-objno.
ELSE.
ENDIF.
Concatenate folder_id-foltp folder_id-folyr folder_id-folno
into tb_key.
swc_create_object attach 'SOFM' tb_key.
SWC_SET_ELEMENT CONTAINER 'SOFM' attach.
LOOP AT CONTAINER.
MOVE-CORRESPONDING CONTAINER TO SIMPLE_CONTAINER.
APPEND SIMPLE_CONTAINER.
CLEAR CONTAINER.
ENDLOOP.
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
EXPORTING
task = 'WS95000377'
IMPORTING
return_code = rc
workitem_id = wi
TABLES
input_container = SIMPLE_CONTAINER
message_lines = ml
message_struct = ms
but my problem is i am getting error in triggering workflow it says"1. The container passed has errors
2.Object type and current value missing for element 'SOFM'"
Please guide me on this..
Thanks,
KishoreHi All,
I have a requirement where i have to add a attachment to workflow while triggering the workflow itself and attach that to user decisition step, i have searched the forum for the same and i got some piece of code which i mention here.
include <CNTN01>.
DATA: attach TYPE swc_object.
DATA:it_objhex TYPE solix_tab.
DATA:container TYPE SWCONT OCCURS 0 WITH HEADER LINE,
SIMPLE_CONTAINER TYPE STANDARD TABLE OF SWR_CONT
WITH HEADER LINE.
DATA :ml TYPE STANDARD TABLE OF swr_messag ,
ms TYPE STANDARD TABLE OF swr_mstruc ,
rc LIKE sy-subrc,
wi LIKE swr_struct-workitemid.
swc_container l_cont.
DATA folder_id TYPE sofdk.
DATA lt_objcont TYPE STANDARD TABLE OF soli.
DATA ls_objcont TYPE soli.
DATA l_obj_data TYPE sood1.
DATA l_obj_id TYPE soodk.
DATA document_id TYPE sofmk.
DATA lt_objhead TYPE STANDARD TABLE OF soli.
data wa_soli type soli.
data wa_solix type solix.
data lt_solix type STANDARD TABLE OF solix .
FIELD-SYMBOLS: <ptr_text> type soli,
<ptr_x> type any,
<ptr_hex> type solix.
define hex_to_cont.
&1 Table of structure SOLIX
&2 Table of structure SOLI
refresh &2.
loop at &1 into wa_solix.
clear wa_soli.
assign wa_soli to <ptr_hex> casting.
move wa_solix to <ptr_hex>.
append wa_soli to &2.
endloop.
end-of-definition.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETER f_n TYPE string.
SELECTION-SCREEN END OF BLOCK b1.
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
region = 'B'
IMPORTING
folder_id = folder_id
EXCEPTIONS
OTHERS = 1.
*get the XLS file into a table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = f_n
FILETYPE = 'BIN'
tables
data_tab = lt_solix
IF sy-subrc <> 0.
ENDIF.
l_obj_data-objnam = 'SOFM'.
l_obj_data-objdes = 'test'.
l_obj_data-file_ext = 'PDF'.
hex_to_cont lt_solix LT_OBJCONT.
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
folder_id = folder_id
object_type = 'EXT' "'RAW'
object_hd_change = l_obj_data
IMPORTING
object_id = l_obj_id
TABLES
objhead = lt_objhead
objcont = LT_OBJCONT
EXCEPTIONS
active_user_not_exist = 35
folder_not_exist = 6
object_type_not_exist = 17
owner_not_exist = 22
parameter_error = 23
OTHERS = 1000.
COMMIT WORK.
Data: tb_key(100).
IF sy-subrc = 0.
document_id-foltp = folder_id-foltp.
document_id-folyr = folder_id-folyr.
document_id-folno = folder_id-folno.
document_id-doctp = l_obj_id-objtp.
document_id-docyr = l_obj_id-objyr.
document_id-docno = l_obj_id-objno.
ELSE.
ENDIF.
Concatenate folder_id-foltp folder_id-folyr folder_id-folno
into tb_key.
swc_create_object attach 'SOFM' tb_key.
SWC_SET_ELEMENT CONTAINER 'SOFM' attach.
LOOP AT CONTAINER.
MOVE-CORRESPONDING CONTAINER TO SIMPLE_CONTAINER.
APPEND SIMPLE_CONTAINER.
CLEAR CONTAINER.
ENDLOOP.
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
EXPORTING
task = 'WS95000377'
IMPORTING
return_code = rc
workitem_id = wi
TABLES
input_container = SIMPLE_CONTAINER
message_lines = ml
message_struct = ms
but my problem is i am getting error in triggering workflow it says"1. The container passed has errors
2.Object type and current value missing for element 'SOFM'"
Please guide me on this..
Thanks,
Kishore -
Problem opening .doc files in pages/.xls files in numbers...
My hard drive recently failed and has been replaced. Since the new hard drive was installed, I am unable to open .doc files with pages or .xls files with numbers. I never had this problem before.
I have I-work 09 [Pages 4.0 (727)]
This is the same version I had before (I think) -- At the Apple Store they used a new I-Work disc to install it onto the new hard drive.
I hope someone can help with this!
Thank you! -
WebDynpro: Problem with opening the generated xls file
Hi,
I am new to the WebDynpro for Java world.
I am trying to learn by referring to the sample tutorials on SDN.
I tried executing the sample project for the exporting to excel.
After I down load the generated xls file to my computer and try opening it I get an error message from excel : "Microsoft Excel Viewer cannot open files of this type".
I get the same error message if I try opening the file directly instead of first downloading it.
Please help me out with possible reasons for this.
Thnx in anticipation,
Pravesh Puria.Hi,
Is the content type : application/vnd.ms-excel.
I guess the problem is with identification of the content type.
Regards,
Sujana -
Problem when converting from spool to XLS file
Hey.
I need to get table data from the spool and send it by mail in an xls file.
so this is what i have done:
I have used the FM 'RSPO_RETURN_ABAP_SPOOLJOB' to get the data table from the spool.
then i am sending the data table in an xls file via the FM 'SO_DOCUMENT_SEND_API1'.
the problem is that the xls file that i am getting through the mail is defected.
All the contents of the spool is located in the first row, first column.
How can i fix it?
Thanks, Barak.After geting the data in a internal table.from spool......refer this report.....
data: p_email type somlreci1-receiver
value 'MAIL ID'.
data: begin of it001 occurs 0,
bukrs type t001-bukrs,
butxt type t001-butxt,
end of it001.
data: imessage type standard table of solisti1 with header line,
iattach type standard table of solisti1 with header line,
ipacking_list like sopcklsti1 occurs 0 with header line,
ireceivers like somlreci1 occurs 0 with header line,
iattachment like solisti1 occurs 0 with header line.
start-of-selection.
select bukrs butxt into table it001 from t001.
Populate table with detaisl to be entered into .xls file
perform build_xls_data .
Populate message body text
clear imessage. refresh imessage.
imessage = 'Please find attached excel file'.
append imessage.
Send file by email as .xls speadsheet
perform send_email_with_xls tables imessage
iattach
using p_email
'Example Excel Attachment'
'XLS'
'TestFileName'
'CompanyCodes'.
Form BUILD_XLS_DATA
form build_xls_data .
constants: con_cret type x value '0D', "OK for non Unicode
con_tab type x value '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>horizontal_tab,
con_cret type c value cl_abap_char_utilities=>cr_lf.
concatenate 'BUKRS' 'BUTXT'
into iattach separated by con_tab.
concatenate con_cret iattach into iattach.
append iattach.
loop at it001 .
concatenate it001-bukrs it001-butxt
into iattach separated by con_tab.
concatenate con_cret iattach into iattach.
append iattach.
endloop .
endform.
Form SEND_EMAIL_WITH_XLS
form send_email_with_xls tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription.
data: xdocdata like sodocchgi1,
xcnt type i.
Fill the document data.
xdocdata-doc_size = 1.
Populate the subject/generic message attributes
xdocdata-obj_langu = sy-langu .
xdocdata-obj_name = 'SAPRPT' .
xdocdata-obj_descr = p_mtitle .
Fill the document data and get size of attachment
clear xdocdata.
read table iattach index xcnt.
xdocdata-doc_size =
( xcnt - 1 ) * 255 + strlen( iattach ).
xdocdata-obj_langu = sy-langu.
xdocdata-obj_name = 'SAPRPT'.
xdocdata-obj_descr = p_mtitle.
clear iattachment. refresh iattachment.
iattachment[] = pit_attach[].
Describe the body of the message
clear ipacking_list. refresh ipacking_list.
ipacking_list-transf_bin = space.
ipacking_list-head_start = 1.
ipacking_list-head_num = 0.
ipacking_list-body_start = 1.
describe table imessage lines ipacking_list-body_num.
ipacking_list-doc_type = 'RAW'.
append ipacking_list.
Create attachment notification
ipacking_list-transf_bin = 'X'.
ipacking_list-head_start = 1.
ipacking_list-head_num = 1.
ipacking_list-body_start = 1.
describe table iattachment lines ipacking_list-body_num.
ipacking_list-doc_type = p_format.
ipacking_list-obj_descr = p_attdescription.
ipacking_list-obj_name = p_filename.
ipacking_list-doc_size = ipacking_list-body_num * 255.
append ipacking_list.
Add the recipients email address
clear ireceivers. refresh ireceivers.
ireceivers-receiver = p_email.
ireceivers-rec_type = 'U'.
ireceivers-com_type = 'INT'.
ireceivers-notif_del = 'X'.
ireceivers-notif_ndel = 'X'.
append ireceivers.
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = xdocdata
put_in_outbox = 'X'
commit_work = 'X'
tables
packing_list = ipacking_list
contents_bin = iattachment
contents_txt = imessage
receivers = ireceivers
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
endform.
Reward IF.........
Regards
Anbu -
I'm one of the few idiots in the world who use the "Pages" App. Whenever I open an XLS file. "Numbers" quits - siting use of SFCompatability plugin. Reports to Mac. Problem remains constant?
When you get the SF Compatibility plug in message something in the installed iWork part is corrupt. You ned to uninstall and install iWork again
You cannot completely delete iWork by moving the iWork '09 folder to the Trash. Instead, use Yvan Koenig's script:
• Go to http://www.box.com/s/00qnssoyeq2xvc22ra4k
• Choose public_YK > for_iWork'09 > other_iWork'09 items
• Click on uninstall iWork '09.zip, decompress it, open it in AppleScript Editor and click the Run button
Restart the computer and install from the iWork disc. Do the Software updates too.
Maybe you are looking for
-
How can I have one calendar on one machine with 2 users
I just replaced my macbook with a mac mini. I created a second account, for my wife, on the machine. Being 2 retired people, we don't need separate calenders. In fact, we often need to see what the other is doing. So, what i'd like to do is have o
-
Error while loading shared libraries: libdb.so.3
Hi, While running adconfig, I am getting below error: /iAS/Apache/perl/bin/perl: error while loading shared libraries: libdb.so.3: cannot open shared object file: No such file or directory. It is new cloned environment of 11.5.10.2 with 11g db on lin
-
Extremely slow printing of PDF documents on networked HP 5000 DN. Printing about a page a minute. Files have been reduced in size using Acrobat. No recent software changes. Printer is networked using HP Jet Direct print server. Printing in other ppli
-
Shared Storage is not showing in SErver pool physical disk .
Hi i have added couple of images to give you exact picture what i am doing .. please have a look OVM can see Shared storage from Openfiler http://www.picpanda.com/viewer.php?file=u1pf8hre1oqufkx6vyr3.gif OVM , SErver Pool (physical disk ) can see Sha
-
Managed server problem.
Hi, I did create Admin server and Managed server on the same host. I have set Managed server (Name, Machine, Listen Address, Listen port enabled, Listen port, SSL listen port enebled, SSL listen port and java compiler) with these parameters. and i ra