Solved

In ASP.NET 4.0 using C#, how would you prevent READ-ONLY status when creating an Excel 2003 file by exporting records from GridView?

Posted on 2013-12-09
3
727 Views
Last Modified: 2013-12-10
I'm writing my first ASP.NET 4.0 application using C# with VS2010.

I am trying to export a stored procedure result set to an Excel 2003 file.

When I create the new Excel file, I notice that the title bar states that it is READ-ONLY.

Do you know how I can modify my following code to get rid of the READ-ONLY status on the Excel file?

My code is in the attachment:
----------------------------
ExcelExport.txt
0
Comment
Question by:zimmer9
  • 2
3 Comments
 
LVL 27

Expert Comment

by:Chinmay Patel
Comment Utility
As this file is considered "downloaded" for security reasons it is marked as read only. Try adding this site to trusted sites section in your browser( still I think it might not work and make the file read only)
0
 
LVL 8

Expert Comment

by:johny_bravo1
Comment Utility
Try this,

var fInfo = new FileInfo(YourFilePathName );
fInfo.IsReadOnly = false;
0
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 500 total points
Comment Utility
I don't think the solution provided by johny_bravo1 will work here. No offense johny_bravo1. This read only message is different than standard read only file scenario. Also this file being generated on server side this method will not have any impact.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now