|
Ya i am creating objects on server. I am pasting the code for your refrence.
Excel.Application ExlApp;
Excel.Workbook ExlBook;
Excel.Worksheet ExlSheet;
DataTable Dt = new DataTable();
SqlConnection ConnObj;
void GenerateExcelSheet()
{
try
{
ConnObj = new SqlConnection("Server =.;database=parnam;user id=sa;password=");
ExlApp = new Excel.ApplicationClass();
//System.Globalization.CultureInfo OldCL = System.Threading.Thread.CurrentThread.CurrentCulture;
//System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
ExlBook = ExlApp.Workbooks.Add(Type.Missing);
ExlApp.Visible = true;
ExlBook.Application.Visible = true;
//ExlSheet = (Excel.Worksheet)ExlBook.Worksheets[1];
ExlSheet = (Excel.Worksheet)ExlBook.ActiveSheet;
ExlSheet.Name = "Report";
string SQL = "select society_code, society_name,shift_date,shift,round (fat,2),clr,snf,milk_qty,totalamount,deductamount,netamount from trucksheet";
// ConnObj = new SqlConnection(ConfigurationSettings.AppSettings["cn"]);
ConnObj.Open();
SqlDataAdapter Da = new SqlDataAdapter(SQL, ConnObj);
DataTable Dt = new DataTable();
Da.Fill(Dt);
ConnObj.Close();
Da.Dispose();
for (int i = 1; i <= 10; i++)
{
((Excel.Range)ExlSheet.Cells[1, i]).Font.Bold = true;
}
((Excel.Range)ExlSheet.Cells[1, 1]).Value2 = "Society Code";
((Excel.Range)ExlSheet.Cells[1, 2]).Value2 = "Society Name";
((Excel.Range)ExlSheet.Cells[1, 3]).Value2 = "Shift Date";
((Excel.Range)ExlSheet.Cells[1, 4]).Value2 = "Shift";
((Excel.Range)ExlSheet.Cells[1, 5]).Value2 = "F.A.T";
((Excel.Range)ExlSheet.Cells[1, 6]).Value2 = "C.L.R";
((Excel.Range)ExlSheet.Cells[1, 7]).Value2 = "S.N.F";
((Excel.Range)ExlSheet.Cells[1, 8]).Value2 = "Milk Quantity";
((Excel.Range)ExlSheet.Cells[1, 9]).Value2 = "Total Amount";
((Excel.Range)ExlSheet.Cells[1, 10]).Value2 = "Deduct Amount";
((Excel.Range)ExlSheet.Cells[1, 11]).Value2 = "Net Amount";
for (int r = 2, i = 0; r < Dt.Rows.Count; r++, i++)
{
for (int c = 1, j = 0; c <= Dt.Columns.Count; c++, j++)
{
// ((Excel.Range)ExlSheet.Cells[k, 3]).Value2 = DtAcc.Rows[0][0].ToString();
((Excel.Range)ExlSheet.Cells[r, c]).Value2 = Dt.Rows[i][j].ToString();
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
|
|
|
|
|
This will create and open an excel spreadsheet on your server, which has a couple of problems:
1. Clients on remote machines aren't going to be able to see this, it's on the server.
2. You don't close the spreadsheet. Trust me (from experience as a junior dev), it doesn't take too many instances of excel to be open before you bring a server to its knees.
If you want to display an excel spreadsheet to a client, you can display your data in an html table and then set appropriate headers to tell the browser what you are downloading is Excel. This should then enable the user to view it in Excel.
|
|
|
|
|
Thanks Sir.
I will try.
Warm Regards
Rishi
|
|
|
|
|
I'm working on a web app for work using asp.net 2.0 that will be accessible only on our intranet. I was wondering if there is a way check for installed software on the client machines, and even interact with the client software via asp.net 2.0(+). Assuming also that all the machines are running windows xp SP2 or later. For example ... updating the outlook address book.
|
|
|
|
|
You may need to have an ActiveX Control to achieve that. The default JavaScript or HTML may not have that privilege to interact with the local machine (system) settings.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
ok ... I've never done any ActiveX programming before. Any suggestions on where to start? I already know what functionality I need. Can I do activeX in .Net ?
|
|
|
|
|
I got this[^], when I searched in google.
|
|
|
|
|
I have a messagebox , which i call on the form load in the java script using the onload fucntion in the body tag.
when the form loads it automatically gets invoked.
i have a button too, on clicking the button , again the message box gets appeared.How i should avooid it.
<head runat="server"><br />
<script language="javascript" type="text/javascript"><br />
var a;<br />
a = false;<br />
function abc()<br />
{<br />
if(!a)<br />
{<br />
alert('hi');<br />
}<br />
<br />
}<br />
</script><br />
<title>Untitled Page</title><br />
</head><br />
<body onload="return abc();"><br />
<form id="form1" runat="server"><br />
<div><br />
<asp:Button ID="Button1" runat="server" Text="Button" /></div><br />
</form><br />
</body>
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Since it is a ASP:Button (Server Control), I guess, it is posting back and after postback, the page gets painted afresh causing the web browser to invoke the onLoad event handler.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Hi
Can any one please let me know wht's the best approach if i have to change the theme of my web application on different occasions in ASP.NET,thankx in advance, Reply ASAP,
Regards,
|
|
|
|
|
How about applying customized stylesheets mapped for each theme?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Have you looked at ASP.net 2.0 themes?
|
|
|
|
|
I have a master page . and a web page , it has master page properties,
Now in this web page i drag dropped a table , in the first rows of table , i drag dropped the script manager control, afterwards , i viewed the source file (html) then i the script manager tyag was shown underlined and was implying the error message
Script manager is now the known element.This can occur if there is a compilation error in the website.
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Forms_Default" Title="Untitled Page" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table>
<tr>
<td style="width: 100px">
<asp:ScriptManager id="ScriptManager1" runat="server">
</asp:ScriptManager></td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
</table>
</asp:Content>
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Help! I am a beginner in ASP.NET.
I have this code below to display images from my SQL Database to my ASP.NET website. But still wont work. What did I miss? Can someone please help me sort this?
Your help is greatly appreciated. Thanks.
==========================
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="4" RepeatDirection="Horizontal" DataKeyField="imgData">
<ItemTemplate>
<asp:Label ID="EmployeeNameLabel" runat="server" Text='<%# Eval("EmployeeName") %>'>
</asp:Label><br />
Department:
<asp:Label ID="DepartmentLabel" runat="server" Text='<%# Eval("Department") %>'>
</asp:Label><br />
<asp:Image ID="Image1" runat=server ImageUrl='<%# Eval("imgData", "{0}") %>'/>
</ItemTemplate>
</asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MYSQL%>"
SelectCommand="SELECT [EmployeeID], [EmployeeName], [Department], [imgData] FROM [tblStaff]">
</asp:SqlDataSource>
aigreen.net
|
|
|
|
|
imgdata is of image type?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Yes, it is an image type. I am getting problem in my code expression in binding to image url just to display my image using datalist.
aigreen.net
|
|
|
|
|
whar code u r using ? can i see it?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Below is the whole code: in ASP.NET
=======================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Display.aspx.vb" Inherits="Display" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="4" RepeatDirection="Horizontal" DataKeyField="imgData">
<ItemTemplate>
<asp:Label ID="EmployeeNameLabel" runat="server" Text='<%# Eval("EmployeeName") %>'>
</asp:Label><br />
Department:
<asp:Label ID="DepartmentLabel" runat="server" Text='<%# Eval("Department") %>'>
</asp:Label><br />
Position:
<asp:Label ID="PositionLabel" runat="server" Text='<%# Eval("Position") %>'></asp:Label><br />
email:
<asp:Label ID="emailLabel" runat="server" Text='<%# Eval("email") %>'></asp:Label><br />
<asp:Image ID="Image1"
runat=server
ImageUrl=
'<%# Eval("imgData", "{0}") %>'
/>
<br />
<br />
</ItemTemplate>
</asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MYSQL %>"
SelectCommand="SELECT [EmployeeID], [EmployeeName], [Department], [Position], [email], [rank], [imgData] FROM [tblStaff]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
aigreen.net
|
|
|
|
|
if u have a image datatype , then for retrieving the pic u
http://aspalliance.com/140_Retrieving_Images_from_SqlServer_in_ASP_NET[^]
Hope this will help u.
Please let me know if u still face the problem.
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
How can i make the dsn for sql server 2000 programatically?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
How should i make a crystal report formula field for the date
In the database it is 12/12/2000 23:10:12
i want 12/12/2000
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Hello,
I have datatable and it is populated with some values.
Is it possible to add a column in an exiting datatable now with a auto increment values?
I am trying like this but it does'nt wotk
dslistItems1.Tables[0].Columns.Add("ID", Type.GetType("System.Int32"));
DataColumn[] pk = new DataColumn[1];
pk[0] = dslistItems1.Tables[0].Columns["ID"];
//dslistItems1.Tables[0].PrimaryKey = pk;
dslistItems1.Tables[0].Columns["ID"].AutoIncrement = true;
dslistItems1.Tables[0].Columns["ID"].AutoIncrementSeed = 1;
dslistItems1.Tables[0].Columns["ID"].ReadOnly = true;
This code doesn't populate the values in the column
Regards,
Pavas
|
|
|
|
|
You are trying to use this code to create a new column in the database? The DataSet is a disconnected, in-memory representation of the database, if you want to add a column into the actual database table you'll need to issue an ALTER table sql statement.
only two letters away from being an asset
|
|
|
|
|
No I do not want to add it to database table. I have a populated datatable and then I want to add an autoincrement datacolumn to a data table.
The purpose is I want to create relations among other datatables present in the dataset.
Regards,
Pavas
|
|
|
|
|