|
Hi,
My requirement is to dynamically create an ExcelSheet from dataset with two sheets as binding table[0] to Sheet1 and table[1] to Sheet2.
I have tried with Interop.Office.Excel,it throws "Cannot access the file" error.
Anyone please help me out to solve this Or please suggest any other better way to implement this.
Beula.
|
|
|
|
|
Find following code for the same.
Excel.Application oXL = new Excel.Application();
Excel._Workbook oWB = (Excel._Workbook)(oXL.Workbooks.Add( Type.Missing ));
Excel._Worksheet oSheet = (Excel._Worksheet)oWB.Sheets["Sheet1"];
oSheet = (Excel._Worksheet)oWB.ActiveSheet;
oSheet.Name = "Tasks";
oSheet.Cells[1, 1] = "CLIENTS";
oSheet.Cells[1, 2] = "ASSIGNMENTS";
oSheet.Cells[1, 3] = "STATUS";
oSheet.get_Range("A1", "C1").Font.Bold = true;
oSheet.get_Range("A1", "C1").VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
oSheet = (Excel._Worksheet)oWB.Sheets["Sheet2"];
oSheet = (Excel._Worksheet)oWB.ActiveSheet;
oSheet.Name = "Clients";
oSheet.Cells[1, 1] = "CLIENTS";
oSheet.get_Range("A1", "A1").Font.Bold = true;
oSheet.get_Range("A1", "A1").VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
oSheet = (Excel._Worksheet)oWB.Sheets["Sheet3"];
oSheet.Delete();
oWB.SaveAs("F:\\Test.xls", Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
oXL.Quit();
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Hi guys.
How can i crop a image while uploading in asp.net using c#.
Please help
shafiq
|
|
|
|
|
|
Hi i am using window.createPopup()in javascript it gives error in firefox but works in ie.How can it be solved
|
|
|
|
|
There is no cross compliant direct equivalent of window.openPopup() method. Its IE only.
If you want to emulate the behavior of 'window.openPopup()', use 'window.open()' along with any 3rd party Javascript Drag and Drop (D&D) API.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Dear sir ,
I m want to be an IT professional & have also an interest built the website . so please concern how to start with asp.net as a beginner.
Thanking You.
|
|
|
|
|
|
You can start from here[^].
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
I would suggest purchase a good book and follow it.
Jumping from topic to topic on internet will not clear your all the basics.
|
|
|
|
|
Hi,
I have a number of reports, one for each question on a questionnaire. They're all supposed to be pie charts and show the results as a "Yes"/"No" split.
Rather than write a separate report for each question, I'd like to create one report called (for example), "generic.rdlc". I would then load this report and dynamically set a data-source to it. All I'd then have to do is change or set the column name to report on.
Can anyone suggest a way of doing this?
The report .rdlc format appears to be a basic XML file and I can find where to set the column, so I guess I could write the column name to the file before I load it. Is that really the best way to do it though? Is there not an API method I can use to "poke" a value into the report?
Incidentally, I'd also like to set the name of the report so I can title it appropriately - again, surely I shouldn't have to write this value to the report file directly?
Thanks for any help offered
|
|
|
|
|
Hi there guys.
Background:
Im currently developing a website that displays data retrieved from MS SQL Server on a chart with MS Charts. The data stored in MS SQL Server table is a temperature measurement taken every second. Every thing works fine. As long as i dont exceed 1 hour of data points. Well up to 4 hours sometimes work as well. But as sson as I increase the range of datapoints to display on the chart(using fastline series) it takes forever and even sometimes times out.(Im using Microsoft Visual Basic 2008(C#) ASP.NET and MS Charts)
Question:
1.Is there another chart application that handles large amounts of data beter.
There is several available but I cant say which will handle large data quantities beter.
(and this is for a University final year project so the budget is very tight)
2.Is there a way to maybe speed up MS charts.
3.And finally I even tried to filter my SQL query to return only every 60th row which I dont mind on say a 12 hour chart. But I cant seem to find any solution to return every nth row that works.
Thanks in advance.
Any help will be much appreciated.
Cobus
|
|
|
|
|
you need to optimize your sql queries.
Everything Is Possible!
|
|
|
|
|
Suresh Dayma wrote: you need to optimize your sql queries.
Thanx. I figured that would be the best. Building a custom query to select only every 60th row. Could just not find a good solution to such a query.
Current solution that ive got that is working is creating an empty data table and then using a for statement to select a specific row and appending it to the datatable with the row identifier as the for counter multiplied by 60 or whatever the case may be until the spesified date or time is reached. Thus creating a table with the relevant time span but only selected values.(thus painting the chart is much faster due to less values)
This works fine just feels cumbersome and sloppy. Well thanks so far.
|
|
|
|
|
I have a master page and set it's back ground color in the body tag . Now that is fine for the Master page. How do I set the back ground color of the content page to a different color?
Thanks,
Steve Holdorf
|
|
|
|
|
Hi,
You cannot set the background color of a content page since it does not have a body tag.
The work around is to create a inside the ContentPlaceHolder and change its color.
Here is the code
<div style="background-color: #FFFF00; width: 100%; height: 100%">
</div>
Hope this helps.
Sujoy Upadhyay
|
|
|
|
|
You are not right. You can do the change. See my post below.
|
|
|
|
|
Add runat="server" and ID attribute of body tag in Master Page.
<body style="background-color:Gray" id="masterBody" runat="server">
Add a new PageBackground property in master page code behind and in page load assign the property value in body style.
public String PageBackgound { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(PageBackgound))
{
masterBody.Style.Add(HtmlTextWriterStyle.BackgroundColor, PageBackgound);
}
}
In your content page get the master page reference and assign PageBackground property value
MasterPage myMaster = (MasterPage)Page.Master;
myMaster.PageBackgound = "#ccff99";
Hope this will solve your problem.
|
|
|
|
|
Thanks for providing the code.
I am trying to compile the code you have provided.
It is giving me error
'MasterPageCP.PageBackgound.get' must declare a body because it is not marked abstract or extern
Please help
Sujoy Upadhyay
|
|
|
|
|
Code is valid - it should work fine. Go in to the property pages of your project and make sure that the "Target Framework" is .NET 3.0 or 3.5.
|
|
|
|
|
This wont work for .Net 2.0?
Sujoy Upadhyay
|
|
|
|
|
In 2.0 , you need some changes in property declaration
private string _background;
public String PageBackgound {
get { return _background; }
set { _background = value; }
}
|
|
|
|
|
Steve Holdorf wrote: set it's back ground color in the body tag . Now that is fine for the Master page
change style tag with class, because it to difficult to override style tag from content page
for example in masterpage
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style>
.bodyClass
{background-color:Red;}
.conetntpage
{background-color:White;}
</style>
</head>
<body class="bodyClass";>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
now in content Page PageLoad
public partial class contentpage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language=\"javascript\">");
sb.Append("document.body.className=\"conetntpage\";");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "MyScript", sb.ToString());
}
}
Hop this will help you
Raju.M
|
|
|
|
|
Everything above looks great; however, someone indicated that all I have to do is set a style background-color in the content page to a different color. If this is true in which content page tag do I set the background-color style?
Thanks,
Steve Holdorf
|
|
|
|
|
Got it working. Just did this:
Add this in the master page head
<asp:contentplaceholder id="head" runat="server">
<asp:contentplaceholder id="head" runat="server">
Set some background color to whatever control you want, either div or table etc in the master page.
Then in content page, you can set the style in its head,
If you do not have any head section in the master page and insert style in content page, you will get an error
content page will look like this:
view plaincopy to clipboardprint?
<asp:content id="Content1" contentplaceholderid="head" runat="server">
body,html
{
background-color: White;
}
Thanks for all of you guys helping me.
Steve Holdorf
|
|
|
|