/    Sign up×
Community /Pin to ProfileBookmark

Excel export problem

Hi, I’m trying to implement an Excel export in one of my products.
I’ve decided to use two different export types. Which one is used depends on whether or not Excel is present on the server.
– A COM-application which works fine
– A header-based export for servers without Excel.

Now the header-based export looks like this:

[code=php]header(“Content-type: application/x-msdownload”);
header(“Content-Disposition: attachment; filename=export.xls”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Pragma: no-cache”);
header(“Expires: 0”);
print “$reportnamen$top1n$top2nn$reportheadern$data”; [/code]

But there’s two problems:
1. All values are formatted as ‘Standard’ types, meaning that Excel will determine whether a cell contains a string an integer or whatever. This means that zeros will be cut off phone-numbers and is disastrous for European datetime stamps. Is there any way to force the cellproperties to be formatted as a string?
2. [COLOR=Red]And even more important[/COLOR], when I create the export and open it directly, the sheetname is called .xls]export[1]. This cannot be altered without saving it first and generates an error message when the user tries to create a graph from the data. Is there any way to give the sheet a ‘normal’ name?

I really really hope someone can help me. If you’re not sure, just give a suggestion and I’ll gladly try it.

Thanks in advance

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @ava spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...