Saving a spreadsheet from .Net Web Forms application under Vista

D

DaveWadd

I have a web forms application that uses Excel to generate a spreadsheet. I
need to save that spreadsheet by calling the SaveAs routine. I have no
problems with the code running under XP. Running under Vista I cannot save
the spreadsheet. I was originally trying to save it to the App_Data
directory that is created in c:\Program Files\MyApp\. Apparently no matter
what I do Vista will not allow me to save a file anywhere under Program
Files. I've tried using the SpecialFolder options for MyDocuments and
Internetcache - those don't work under Vista either. I also tried to save to
the c:\Windows\Temp directory, again without success.

Can somebody tell me what I need to do in order to save a spreadsheet in a
manner that works under both XP and Vista?
 
D

DaveWadd

The error I get depends on which directory I try to use. Most of the time it
tells me it can't find a portion of the path even though the path displayed
exists. When I tried to write to personal documents area it told me I did
not have rights to the root of the C drive. I have no idea why it would be
trying to write to c:\ in that case.
 
J

JLGWhiz

Ffrom XP to vista requires different file extensions, and if you are not
using the correct ones, it will tell you that the operation failed, without
telling you why. I suppose you knew that. If it is not finding the path you
want, go to windows explorer and locate a file in a folder that you want to
save the file to. Right click the file and select properties from the drop
down menu. On the general tab there is a location caption. That is the path
to that file, so if you copy that path, then you should be able to paste that
in the SaveAs dialog box and add the file name. If it still fails, you might
need technical assistance.
 
D

DaveWadd

I don't think I've explained the problem well enough. I am doing all of this
in a C# web forms program by automating Excel using the Interop libraries.
The spreadsheet to be saved is being created and saved by that program
without user intervention. Here is the call that works in XP but not in
Vista:

theName = "FinalReport" +
String.Format("{0:yyyyMMddhhmmssttt}", DateTime.Now) + ".xls";


oSheet.SaveAs(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + @"\" + theName,
Excel.XlFileFormat.xlExcel7, Type.Missing, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top