.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Write excel file on server to transfer to user, including colours

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

I want to export a large amount of data to an excel file (30,000 plus). This is no problem. The problem is that, one of the columns needs to be coloured green according to the data within it.

For example, the colour contains percentages, and when the percentage is over 70%, then the cell needs to be green.

I can do this easily using a Datagrid/Gridview. However, because of the amount of data, my server is crashing with a SystemOutOfMemory exception.

What I would like to do is use a tool to write the data to an excel file, and then transfer the file. Is this possible?

View Complete Post

More Related Resource Links

Insert Excel Data via File Upload into sql server database???

Hi all, I have requirement that User can Upload the Excel Sheet Data to sql server Database at once. How i do that Any Article or hint is apperciated.   Regards 

how to write data to excel file

Hi, can any one plz tell me how to write data in and excel sheet. when i retrive the data by foreach loop i want to dynamicaly create a excel sheet and save data inside the sheet.  Please help

if ssis package writes to excel file that might be open by a user

I have written a package that writes to an excel file to a network folder. Eventually this package will run as a job. What is the best way to handle the situation where someone opens the file or inadvertantly leaving it open while the package is running and and stop the package.? No one needs to modify or write anything to this file after it is finished

importing excel file into sql server 2005 in asp .net using c#

Dear friends i want to import excel file into sql server 2005 in asp .net using c# can anyone help me? rgds,RK

Problem while 2 User write in a File a the Same time


Hi Everyone
I am facing a problem while a user is going to write in a file. My question is that if a User A open a file and start writing in file usin FileStream, if at the same other user try to access this file and try to write in it then he should wait until User A does not complete his work and close writer object.  Waiting for quick response. It is very urgent. Thanks in advance.


can I use SQL Server to export an excel file directly?


I just want to know except use owc

can we use SQL Server to export excel file ?

if it can be , how to do? thanks alot

Import Excel File in SQL Server


Dear all,

I have to create one page where user will upload the excel file in SQl Server and system should check following things

1.Sheet Name should be always sheet1

2.System should check the column names

3.System should show the message that these many rows has been loaded



Import Excel-File (OPENROWSET) on x64 SQL Server


Hi, recently I encountered the following problem:

I tried to execute a stored procedure on the newly installed SQL 2005 Server (now on x64 Win Server 2003) which imports an Excel-File into a DB table.

We use OPENROWSET to access the Excel data. But I recognized this is dependent on Jet OLE DB which seems is not available for x64 windows.


Is there another way to import excel data using a stored procedure.


thank you in advance, rene

How can I download an Excel file saved on the same server as an asp.Net website?



I able to successfully see all the Excel files in the given folder using the datagrid and code below. Now I would like to be able to click the link to the file, or add a button, to get a download file dialog box. Can someone please help me.



<asp:datagrid id="FileGrid" runat="server" 
    AutoGenerateColumns="False" AllowSorting="True">
        <asp:TemplateColumn HeaderText="File" >
                <asp:HyperLink id="systemLink" runat="server" 
                NavigateUrl='<%# DataBinder.Eval(Container, "DataItem") %>'
                Text='<%# DataBinder.Eval(Container, "DataItem") %>' />
        <asp:BoundColumn DataField="Length" HeaderText="File Size" />
        <asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Modified" />


Imports System.IO

Partial Class pageclass

Import Excel File to Sql Server on a 64 bit machine


I need to import Excel (xls - 2003-2007) data into a Sql Server 2008 database. Both the Excel file and the database live on a Windows Server 2003 R2 sp2 64 bit machine.  I’m fine with it running in 32 bit mode but it all needs to happen on the same server. Also, I would like it to run in T-Sql but as a fallback we can do this in SSIS.

My T-Sql code which runs fine on a 32 bit machine is as follows:

SELECT * Into #TempTable From OpenRowSet('Microsoft.Jet.Oledb.4.0','Excel 8.0;Database=\\Servername\Folder\filename.xls;HDR=NO;IMEX=1', 'select * from [Main$]')


On the 64 bit server:

How to write Excel File in C#

I want to write excel file from the datatable

linked server to excel file



I,m trying to make a linked server connection to an excel 2007 file. I have SQL server 2008 R2 and i have used the code below. When i test the connection to the linked server it works but i still only get this error (se below). I also tried different security settings such as Not be made, Be made without using a security content, Be made using the logins current security content and be made using this security content Remote login = Admin, with password (password left blank). someone and ideas on how to solve this?



Msg 7399, Level 16, State 1, Line 1

The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "XLFile" reported an error. The provider did not give any information about the error.

Msg 7330, Level 16, State 2, Line 1

Cannot fetch a row from OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "XLFile"

EXEC sp_addlinkedserver
@server = 'XLFile', 
@srvproduct='ACE 12.0',
@datasrc= 'C:\File2.xlsx',
@provstr='EXCEL 12.0; Hdr=Yes';

Select *
FROM XLFile...[Sheet1$]

Arne Olsson

Have a user save a file from a server


I create an xml file from a csv file that a user uploads. What I want to do is display a link that says click here to download and have it pop up a box where they can save the specific file I just created. I can't seem to find any examples on this. Can someone help me out?

Write a file on server via WCF is not working


i am trying to write file on the server through client side using jquery and it looks the writing this file on the WCF services is not working on the DEV box but i have tested on my local machine and it works as expcted and i get this error on fiddler: what might be wrong here????

ReadResponse() failed: The server did not return a response for this request.

public string GetKMLFile(long Id) 
KMLFile k = LoadData(id); 
// create a writer and open the file 
using (StreamWriter writer =

Read/Write Excel file with formulas and accessing cell ranges


I need to read and write data to some specific cells in an excel file.
I want to send some values to cells from front end i.e asp.net web page and after calculation from excel the value should be send again to asp.net

Example if cell A1 = 10 Cell B1 = 20 then C1 cell should have value of A1 + B1 i.e 30 should be displayed and this cell C1 value should be fetched and displayed in ASP.NET Page or some front end

Secondly is it possible to use formula and ranges from asp.net

How to add a user DSN for SQL Server Compact Edition Database File (filename.sdf)

I'm very new to database operations, so bear with me.
I have a SQL Server Compact Edition Database File (filename.sdf).
I can connect to this database file (filename.sdf) using MS SQL Server 2008 with server type set to SQL Server Compact Edition. I can select data and do queries.
But in order to connect to the database file from National Instruments LabWindows CVI, I have to create a User DSN under my ODBC Data Source Administrator.
None of the samples represents a *.sdf file.
I clicked on Add and get a window called Create New Data Source.
I am asked to Select a driver for which you want to set up a data source.
I tried the SQL Server option, but that did not seem to work.
The database connectivity test always fails.
Is there a better driver with which to communicate with a sdf file?

MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend