|
Well it is very simple to create excel files from asp.net code.
The following is the sample code to create one with font and style settings etc.
----------------------------------------------------------------------
//Write a table structure with all formatting you need (e.g. font, etc.)
string strHtml="
strHtml+= ""
strHtml+=""
strHtml+=""
strHtml+="Name | Color | Formatting | Ketan | This is Red Color Font | None | Abc | NA | None | Xyz | NA | This is bold text | "
//Clear the Response Headers
Response.Clear();
Response.Charset = String.Empty; // String.Empty();
//Set Content Type and add header
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=abc.xls;");
this.EnableViewState = false;
System.IO.StringWriter myTextWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter myHtmlTextWriter = new System.Web.UI.HtmlTextWriter(myTextWriter);
HtmlGenericControl gn = new HtmlGenericControl();
gn.InnerHtml=strHtml;
gn.RenderControl( myHtmlTextWriter);
Response.Write(myTextWriter.ToString());
Response.End();
----------------------------------------------------------------------
If you need to embed excel sheet functionality, you need to work out more.
Regards,
Ketan Majumdar.
|
|
|
|
|
Thank you Mr.Ketan Majumdar.
Haridas.R
harisofttech@hotmail.com
"Achievement is not a destination, its a journey "
|
|
|
|
|
There are a couple of ways to create the Excel document:
+ Use the Automation to create the Excel file, however this option is not recommended at the server side.
+ Create the Excel file in XML format.
+ Use a third party component to generate the Excel file without using Automation.
|
|
|
|
|
hello
as u know asp.net have different controls i want to make
datagrid as webcontrol which is use in every web forms
can u suggest me some idea for this?
|
|
|
|
|
Just follow the instructions given below
First of all,take datagrid from toolbox and paste it on webform1.aspx
1) Now Use some database to connect to table. Use its connection string.
e.g. Dim con as new sqlconnection
con.ConnectionString="Data Source=servername;Initial Catalog=pubs;User Id=sa;Password=sa;Persist Security Info=False;";
2) dim ds as dataset()
dim cmd as sqlcommand = new SqlCommand()
cmd.Connection=cn
Dim Query As String = "select * from EET_ACCRIGHTS"
'use above code for ref.
Dim MyCommand As SqlDataAdapter
MyCommand = New SqlDataAdapter(Query, con)
DS = New DataSet
MyCommand.Fill(DS, tablename)
3) Now use following code
If con.State = ConnectionState.close Then
con.Open()
End If
datagrid1.datasource=ds.tables(0)
datagrid1.databind()
If con.State = ConnectionState.Open Then
con.Close()
End If
Balasaheb
Software Developer
Platform: Asp.net,vb.net
Database: SQL Server 2000
|
|
|
|
|
Hello All,
I created a bit map and it is saved to a jpg file. The code is:-
oBitmap.Save("c:\\codes\\gen_img.jpg", ImageFormat.Jpeg);
I want the file to be given by the user(save dialogbox should come and the filename should be given by the user and the location "SHOULD BE" on the server),i.e, i need to get the location as well as the filename from the dialog box and should be given instead of the hard-coded one.
Hope Anyone can find me a Solution for this!
regards,
jeeva
|
|
|
|
|
If you mean that the user should upload the file:
Put a FileUpload control in the form. When the file has been uploaded you get it from the PostedFile property of the control.
If you mean that the user should get a dialog to choose a location on the server:
You have to build the dialog yourself in the form of a web page. There is no way that the user can directly access the file system of the server.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks For The Help!!!!!!!!!!!!!!!;)
|
|
|
|
|
How to find how many years,months,dates in two different dates
format dd/mm/yyyy
eg 01/06/2001 to 11/06/2006
ouput:5 years,0months,10 days
parthiban
|
|
|
|
|
in C#?
DateTime dt1 = new DateTime(2001,6,1);<br />
DateTime dt2 = new DateTime(2006,6,11);<br />
<br />
TimeSpan ts = dt2.Subtract(dt1);
The TimeSpan class has propertiessuch as "TotalDays" which will give you the info you want.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
hi ,
you can use SQL also to find the difference between two dates.
the code looks like :
DATEDIFF(part of the date,start date,end date)
"part of the date" means whether its day,month or year of a date variable.
Tirthadip
Live life to the fullest
|
|
|
|
|
Hello Everybody,
I need help from all of u, pls help me for following code.
I have given number for each line, only for ref. When u copy the code, pls remove the numbers given and do modification.
The original code is in C# that converted into VB.net using converter.This code is perfectly working in C# without any error and waring Now I'm facing problem.
Now problem is, the line number 20 need raiseEvent, I don't know how to raise event in vb.net
Pls concentrate on line 20. Pls let me know how to declare and raise event.
1 Public Class CreateItemTemplateRadioButton
2 Implements ITemplate
3 Dim strText As String
4 Dim strRadioButtonName As String
5 Dim Visibility As Boolean = True
6 Dim blChecked As Boolean = False
7 Public Sub New(ByVal RadioButtonName As String, ByVal Text As String, ByVal AutoCheck As Boolean)
8 Me.strText = Text
9 Me.strRadioButtonName = RadioButtonName
10 Me.blChecked = AutoCheck
11 End Sub
12 Public Sub New(ByVal RadioButtonName As String, ByVal Text As String, ByVal AutoCheck As Boolean, ByVal Visibility As Boolean)
13 Me.strText = Text
14 Me.strRadioButtonName = RadioButtonName
15 Me.Visibility = Visibility
16 Me.blChecked = AutoCheck
17 End Sub
18 Public Sub InstantiateIn(ByVal objcontainer As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
19 Dim rad As HtmlInputRadioButton = New HtmlInputRadioButton
20 rad.DataBinding += New EventHandler(rad_DataBinding)
21 objContainer.Controls.Add(rad)
22 End Sub
23 Private Sub rad_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
24 Dim rad As HtmlInputRadioButton = CType(sender, HtmlInputRadioButton)
25 rad.Value = strText
26 rad.Checked = blChecked
27 rad.Visible = Visibility
28 End Sub
29 End Class
Balasaheb
Software Developer
Platform: Asp.net,vb.net
Database: SQL Server 2000
|
|
|
|
|
|
Thanks for ur help,
I have tried for the whole day, finally I got answer from my collegue last evening.
So now its working fine. Thanks for also ur help.
Keep in touch
Balasaheb
Software Developer
Platform: Asp.net,vb.net
Database: SQL Server 2000
|
|
|
|
|
I have problem with sending email in asp.net page.
When user register in my page i want to send to user email address directly, if they use Yahoo mail the message send to Bulk mail not Inbox, but other mail is ok, How can i correct it?
................
|
|
|
|
|
Hi,
Yahoo is using many filters to check spam.
It depends on your server. It must have a public IP and should not be blocked by the Yahoo.
Make sure about these things.
Thanks
Sushant Duggal.
|
|
|
|
|
I don't know how to make sure
................
|
|
|
|
|
When i select a child node and click a button the child nose shoulh
be removed from the tree.
I am using the code
protected void Button2_Click(object sender, EventArgs e)
{
TreeView1.Nodes.Remove(TreeView1.SelectedNode);
}
But the node is not getting removed. I have tried but could not get it.
Can anyone please help me out.
|
|
|
|
|
Are you sure that the Nodes collection contains the SelectedNode?
|
|
|
|
|
Yes.In Quick Watch I am getting the exact value of the selected node.
TreeView1.SelectedNode.
thanks .
bhavna.
|
|
|
|
|
Hi
I have an array of URLs
I wanna display them in the form of hyperlinks using StringBuilder
ie StringBuilderobject.Append("url")
i wanna convert above "url" in the form of hyperlink to be displayed in browser
How do i do
Should i use some script?
please help
Thanks
Jiny
-- modified at 5:36 Tuesday 27th June, 2006
|
|
|
|
|
Hi,
Do you have the URLs in a comma seperated string?
If yes, you can split it into a string array and then generate array of hyperlinks as much as string array lentgh of the URLs.
I hope this will help you,
If not, please explain your situation
Thanks,
Sushant Duggal.
|
|
|
|
|
My code looks something like this
foreach (ResultElement reselem in objres.resultElements)
{
//here sb is object of string builder
sb.Append("<a href="\ + reselem.URL + "\">" + reselem.title + "</a><br />");
}
TextBox1.text = sb.ToString();
Rather than displying it as hyperlink, it displaysas "a href="\......
kindly help, how can display it in the form of hyperlink
Thanks
Jiny
|
|
|
|
|
Place a repeater control on the page that contains a hyperlink control.
bind your collection - objRes.resultElements to the repeater.
In the repeater, bind the url property of the hyperlink control to the URL property and the text to the title property.
This should then display a list of all the urls.
If you are trying to display a clickable url in a textbox, then i don't think that this is possible.
|
|
|
|
|