Skip to Content
-2

Can we write an excel file on application server without using OPEN DATASET ?

Jul 18, 2017 at 11:35 AM

193

avatar image
Former Member

Whenever we write excel file on application server using OPEN DATASET, it actually gets written in text format. It's just that the extension we give is .xls that is why we can open it in excel file. And the problem here is - whenever that excel file is opened in front end, it gives a warning pop-up that "file content and extension do not match, do you still want to open this file". This pop-up I want to avoid.

Can anyone help on this please.

10 |10000 characters needed characters left characters exceeded

The answer to your question is "NO, because the only ABAP statements to write any kind of file are OPEN DATASET + TRANSFER + CLOSE DATASET". Now, to go further, if you create a text file with extension .xls on frontend with exactly the same content as on the application server, then you'll see you get the same popup, so your question should be rewritten to "how to avoid the warning when I open such a file on the frontend, and do I need to change the content of the file to achieve this requirement".

1

Differently said, it's not an ABAP question. Search the web for "xls format doesn't match file extension csv" ("csv" because I guess your actual format is probably the text format CSV)

0
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Mike Pokraka Jul 19, 2017 at 07:08 PM
2

Or save it with extension .csv or .txt

Excel can still open it and won't give the warning since the extension matches the content.

Share
10 |10000 characters needed characters left characters exceeded
Matthew Billingham
Jul 18, 2017 at 01:13 PM
1

Write the Excel file as an actual Excel file. There are many blogs about how to do this using various function modules and methods. Or install abap2xlsx.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Even using abap2xslx will still need to use "Open dataset", so the annoying popup will still be displayed.

1

Why? If the extension is xlsx and the content is xlsx format, why would you get "file content and extension do not match, do you still want to open this file"?

0

I give up ...

0
Horst Keller
Jul 19, 2017 at 08:42 PM
1

Open the file as a binary file. This is the recommended way for all files anyway.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Even in binary mode this popup is displayed. I don't think it is possible to avoid it.

0

No, it isn't. Yes it is.

0
Enric Castella Gonzalez Jul 19, 2017 at 10:36 PM
1

The problem is the internal format of excel because this file not contain excel properties.

If your process isn't in background mode you can use ole2, check this post: https://archive.sap.com/discussions/thread/940817

If not. You can create the same file content like excel

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jul 19, 2017 at 09:09 PM
-2

Sorry, but I don't think it is possible to write anything to the server using anything but OPEN DATASET. And I'm afraid this pop-up will always being displayed, even if you open data set in binary mode. :(

Show 2 Share
10 |10000 characters needed characters left characters exceeded

See Enric's answer.

Other example. Imagine you want to write an image file. Of course it must have the correct binary contents.

So it can be done with OPEN DATASET.

0

Your answer concerning popups is wrong. I've written many files of different formats to the app server using open dataset, and only encountered this problem when the contents don't match the file extension.

Your answer implies that there is something inherently wrong with open dataset that makes it impossible to write files correctly.

0