|
Hello All,
I am using ASP.NET 2005(C#). I want to show and save the excel file on server. For this I opened excel file in iframe and kept a save button outside the iframe. On Page Load I have the following code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
string fileName = AppDomain.CurrentDomain.BaseDirectory + "SaveExcelFile\\Excel1.xls";
Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook ObjWB;
Microsoft.Office.Interop.Excel.Worksheet ObjWS;
Object missing = System.Reflection.Missing.Value;
if (ObjExcel == null)
{
throw (new Exception("Unable to Start Microsoft Excel"));
}
else
{
ObjExcel.Visible = true;
ObjExcel.DisplayAlerts = false;
ObjWB = ObjExcel.Workbooks._Open(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)ObjWB.ActiveSheet;
Session["ExcelObject"] = ObjExcel;
Session["WorkBook"] = ObjWB;
Session["WorkSheet"] = ObjWS;
htxtFileName.Value = "SaveExcelFile/Excel1.xls";
}
}
catch (Exception ex)
{
Response.Write("Page Load Error : " + ex.Message);
}
}
}
and On Save Button Click event I have the following code:
protected void btnSaveFileToServer_Click(object sender, EventArgs e)
{
try
{
if (Session["ExcelObject"] != null && Session["WorkBook"] != null && Session["WorkSheet"] != null)
{
Microsoft.Office.Interop.Excel.Application ObjExcel = (Microsoft.Office.Interop.Excel.Application)Session["ExcelObject"];
Microsoft.Office.Interop.Excel.Workbook ObjWB = (Microsoft.Office.Interop.Excel.Workbook)Session["WorkBook"];
Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
ObjExcel.ThisWorkbook.Save();
}
}
catch (Exception ex)
{
Response.Write("ERROR : " + ex.Message);
}
}
The above code works fine on my machine but when I deploy it on server it gives error "ERROR : Exception from HRESULT: 0x800A03EC" while saving the file back to server.
Please help me.
Thanks in advance.
|
|
|
|
|
Have you tried googling with the error message as the search string. You might find what it means.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Thanks Paul for replying. Yes I have tried but didnt get much help
I am not able to figure out what is the exact problem in the code.
Please help me...
|
|
|
|
|
I've seen this kind of thing happen when there is an instance of Excel, ( or Word, doesn't really matter when using Office Interop ) that is not closed, and a New is invoked the second time through. I'd put a check in your code to make sure you are creating a single instance of Excel, and closing that instance when done with it.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
In btnSaveFileToServer_Click....
ASP.NET 2.0 wrote: Microsoft.Office.Interop.Excel.Worksheet ObjWS = (Microsoft.Office.Interop.Excel.Worksheet)Session["WorkSheet"];
ObjExcel.ThisWorkbook.Save();
Add something like ObjExcel.Quit , so you can dispose of the Excel app when done with it.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
thanks for the reply Paul, but its not working. now the error is coming on page load it self and excel file is not getting saved
Please help me...
Thanks again.
|
|
|
|
|
Well, it's late here. I'm curious as to why this is a problem. I'll write my own little mock up of your code you are trying to do and see what is up. Stay tuned
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hey thanks Paul. I am trying this from yesterday but
First I was getting Error "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005."
I solved that but now getting this error.
Thanks again.
|
|
|
|
|
|
Hi,
I tried your code, I get the error even in my local dev machine.
The error when executing the line "ObjExcel.ThisWorkbook.Save();" is : "Exception from HRESULT: 0x800A03EC".
If you find the solution for the above, pls help me out to solve.
Thanks
Priya
|
|
|
|
|
How to create a setup file for a webbased project which is developed in vs2003/msaccess.
I have created and installed.but it is unable to open.
How to give url??and step step by process i need.please give the steps to create.
i found something on the net but it is now so useful.let me know if anybody is free.
kissy
|
|
|
|
|
Kissy16 wrote: but it is unable to open.
What is unable to open?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
the generated setup file,i have installed in a PC but it is not opening.
kissy
|
|
|
|
|
Does the target PC have the installer requirements to open the setup file? I've run into some machines that need to have the latest version of the Windows Installer stuff installed before setup files will work. Not sure if this is the case in your situation, but I'd double check that.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi All,
I have developed a ASP.NET application and I am using XML webservice.
In there I have set the timeout property as 10 minitues. But I am getting following error after one minitue.
The underlying connection was closed: The connection was closed unexpectedly.
code part is as follows
lobjService = new MyService();
lobjService .Timeout = 10 * 60 * 1000;
object[] results = lobjService .AgentAvailabilities(lobjCriteria);
How can I avoid the exception and take results? .
thanks in advance.
|
|
|
|
|
Hi i want to show my update progress bar in inside modal popup control...,
And same time the parent form have to be disable mode...,
Plz any one guide me
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
To do this, you need to make your calls using AJAX, so that you can update your page during it's progress.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi friends
How import print options in Report viewer? I am using Report viewer control in
my application. But the print image doesnt appear in my application. what wil i
do? I searched in msdn also. They give that to install Activex control. I cant
understood friends. Because without print image how can i print the page?
please give the solutions. Its very important me.
Hopes for ur's reply.
Thanks
Every Successful Person Have A Painful Story
|
|
|
|
|
Hi,
i am developing a website, in that lot of advertisements are there, there is no particular to display the advertisement, means the Advertisement can be in .swf format, .jpg/.gif in any of the format, that is user's choice, for that i am checking the extension and binding to the StringBuilder and assigning to span tag, now it is working fine, but i want server side click event for each image, because client wants no.of clicks on each image so, it needs to store in the database.
Can you please help me out, if any one have solution for this?
Thanks & Regards
Murthy
|
|
|
|
|
hi,
iam unable to color the cells of table i did coding like this but not able to get result any one please suggest me where iam doing mistake .
Dim tbl As Table = New Table()
Dim tr As TableRow = New TableRow()
Dim tc As TableCell = New TableCell()
tc.ColumnSpan = 4
tc.RowSpan = 1
tc.Text = "8AM"
tr.Cells.Add(tc)
Table1.Rows.Add(tr)
Dim tc1 As TableCell = New TableCell
tc1.ColumnSpan = 4
tc1.RowSpan = 1
tc1.Text = "9AM"
tr.Cells.Add(tc1)
Table1.Rows.Add(tr)
Dim tc2 As TableCell = New TableCell
tc2.ColumnSpan = 4
tc2.RowSpan = 1
tc2.Text = "10AM"
tr.Cells.Add(tc2)
Table1.Rows.Add(tr)
Dim tc3 As TableCell = New TableCell
tc3.ColumnSpan = 4
tc3.RowSpan = 1
tc3.Text = "11AM"
tr.Cells.Add(tc3)
Table1.Rows.Add(tr)
Dim tc4 As TableCell = New TableCell
tc4.ColumnSpan = 4
tc4.RowSpan = 1
tc4.Text = "12PM"
tr.Cells.Add(tc4)
Table1.Rows.Add(tr)
Dim tc5 As TableCell = New TableCell
tc5.ColumnSpan = 4
' tc5.RowSpan = 1
tc5.Text = "1PM"
tr.Cells.Add(tc5)
Table1.Rows.Add(tr)
Dim tc6 As TableCell = New TableCell
tc6.ColumnSpan = 4
tc6.RowSpan = 1
tc6.Text = "2PM"
tr.Cells.Add(tc6)
Table1.Rows.Add(tr)
Dim tc7 As TableCell = New TableCell
tc7.ColumnSpan = 4
tc7.RowSpan = 1
tc7.Text = "3PM"
tr.Cells.Add(tc7)
Table1.Rows.Add(tr)
Dim tr2 As TableRow = New TableRow
Dim trcell As TableCell = New TableCell
Dim i As Integer
Dim MyArray() As Integer = {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
For i = 0 To 31
If MyArray(i) = 1 Then
trcell.BackColor = Drawing.Color.Green
Else
trcell.BackColor = Drawing.Color.Yellow
End If
tr2.Cells.Add(trcell)
Next
Table1.Rows.Add(tr2)
In above code second row is not displaying please suggest me where iam wrong .
Regards
Rameez
|
|
|
|
|
Next time, please use the code block tags and post only the code that is causing the problem.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
here is code which causes error row is not created
Dim tr2 As TableRow = New TableRow
Dim trcell As TableCell = New TableCell
Dim i As Integer
Dim MyArray() As Integer = {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
For i = 0 To 31
If MyArray(i) = 1 Then
trcell.BackColor = Drawing.Color.Green
Else
trcell.BackColor = Drawing.Color.Yellow
End If
tr2.Cells.Add(trcell)
Next
Table1.Rows.Add(tr2)
kindly suggest me where iam doing error
thanks
remaeez
|
|
|
|
|
Hello All,
I have been trying to make this work for the last few days with no avail.
I am trying to write a custom composite control that contains a couple of labels and a textbox. I have three properties: Label, Seperator and TextBoxText, all are string and are values of the Label control, Label control, and Textbox control, respectively. When i change the values of the textbox and seperator, the text is persisted when i toggle between the designer and the source code, the label on the other hand, does not. The actual values for all the properties are written as attributes in the control. See code below. Im not sure if im doing something wrong or VS2005 is buggy.
Your help will be higly appreciated. Thank you in advance.
Here is my declarative code:
<cc1:FusionTextBoxOld ID="FusionTextBoxOld1" runat="server" Label="First Name" Seperator="-" TextBoxText="enter first name" />
Here is my control code:
[DefaultProperty("TextBoxText")]
[ToolboxData("<{0}:FusionTextBoxOld runat=server></{0}:FusionTextBoxOld>")]
public class FusionTextBoxOld : CompositeControl
{
Style _LabelStyle = new Style();
TextBox _textBox = new TextBox();
Label _label = new Label();
Label _seperator = new Label();
#region TextBox
[Bindable(true)]
[Category("Appearance: TextBox")]
[DefaultValue("")]
[Localizable(true)]
[PersistenceMode(PersistenceMode.Attribute)]
public string TextBoxText
{
get
{
EnsureChildControls();
String s = (String)ViewState["TextBoxText"];
return ((s == null) ? String.Empty : s);
}
set
{
EnsureChildControls();
ViewState["TextBoxText"] = value;
}
}
#endregion
#region Label
[Bindable(true)]
[Category("Appearance: Label")]
[DefaultValue("Label")]
[Localizable(true)]
[PersistenceMode(PersistenceMode.Attribute)]
public string Label
{
get
{
EnsureChildControls();
String s = (String)ViewState["Label"];
return ((s == null) ? "Label" : s);
}
set
{
EnsureChildControls();
ViewState["Label"] = value;
}
}
[Bindable(true)]
[Category("Appearance: Label")]
[DefaultValue(":")]
[Localizable(true)]
[PersistenceMode(PersistenceMode.Attribute)]
public string Seperator
{
get
{
EnsureChildControls();
String s = (String)ViewState["Seperator"];
return ((s == null) ? ":" : s);
}
set
{
EnsureChildControls();
ViewState["Seperator"] = value;
}
}
[Bindable(true)]
[Category("Appearance: Label")]
[DefaultValue("")]
[Localizable(true)]
[PersistenceMode(PersistenceMode.Attribute)]
public string LabelCssStyle
{
get
{
String s = (String)ViewState["LabelCssStyle"];
return ((s == null) ? "" : s);
}
set
{
ViewState["LabelCssStyle"] = value;
}
}
[Bindable(true)]
[Category("Appearance: Label")]
[DefaultValue(typeof(Style))]
[Localizable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Style LabelStyle
{
get
{
if (_LabelStyle == null)
_LabelStyle = new Style();
return _LabelStyle;
}
set
{
this._LabelStyle = value;
}
}
#endregion
#region Required Label
[Bindable(true)]
[Category("Appearance: Required Label")]
[DefaultValue("*")]
[Localizable(true)]
public string RequiredLabelText
{
get
{
EnsureChildControls();
String s = (String)ViewState["RequiredLabelText"];
return ((s == null) ? "*" : s);
}
set
{
EnsureChildControls();
ViewState["RequiredLabelText"] = value;
}
}
[Bindable(true)]
[Category("Appearance: Required Label")]
[DefaultValue("")]
[Localizable(true)]
public string RequiredLabelCssStyle
{
get
{
EnsureChildControls();
String s = (String)ViewState["RequiredLabelCssStyle"];
return ((s == null) ? "" : s);
}
set
{
EnsureChildControls();
ViewState["RequiredLabelCssStyle"] = value;
}
}
private Style _RequiredLabelStyle;
[Bindable(true)]
[Category("Appearance: Required Label")]
[DefaultValue(typeof(Style))]
[Localizable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Style RequiredLabelStyle
{
get
{
EnsureChildControls();
if (_RequiredLabelStyle == null)
{
_RequiredLabelStyle = new Style();
_RequiredLabelStyle.ForeColor = Color.Red;
}
return _RequiredLabelStyle;
}
set
{
EnsureChildControls();
_RequiredLabelStyle = value;
}
}
#endregion
#region Overrides
protected override void CreateChildControls()
{
this.InitializeComponents();
this.ConfigureLabel();
this.ConfigureSeperatorLabel();
this.ConfigureTextBox();
}
#endregion
private void InitializeComponents()
{
Controls.Add(_label);
Controls.Add(_seperator);
Controls.Add(_textBox);
}
private void ConfigureLabel()
{
this._label.Text = this.Label;
this._label.ControlStyle.CopyFrom(this.LabelStyle);
this._label.CssClass = this.LabelCssStyle;
}
private void ConfigureSeperatorLabel()
{
this._seperator.Text = this.Seperator;
this._seperator.ControlStyle.CopyFrom(this.LabelStyle);
this._seperator.CssClass = this.LabelCssStyle;
}
private void ConfigureTextBox()
{
this._textBox.Text = this.TextBoxText;
switch (this.TextBoxType)
{
case TextBoxType.Email:
this.ConfigureEmailValidator();
break;
}
}
}
|
|
|
|
|
I am at my whits end. I have posted to so many forums and not 1 person can answer my question. Please someone help.
I had to get a new computer and can't use VS.net 2003 or 2005 with Vista. So I have 2008 now. I have an existing website that was built with YahooSiteBuilder. I have a shopping cart page with nothing on it but the background environment because I don't have any buttons on the pages that will use the shopping cart page because YahooSiteBuilder doesn't have a way for me to do that. Just submit and reset buttons. I want an Add to Cart which I can add and then the action will be adding to the shopping cart, but can't do this with sitebuilder. I also have a user form for the newsletter. This is not really my problem or question. My problem is when using asp.net I can create a new website however if I import my sitebuilder site, I must be missing something in how to make this all work together. Looking at my default.aspx page everything looks to go between the , however if I put my HTML code from say my homepage in there, it doesn't look right in the browser. All I want to do is take my current HTML code or current site and use it with this asp stuff. I have found nothing that discusses in any textbook or on any website how you use asp.net with an existing incomplete website. As I stated the site lacks my buttons to add items to shopping cart and it lacks working with the form that I have. Everything else is done. I find that if I am unable to import the existing I am going to have to start all over again and build the site from scratch using asp.net which I do not want to do. There has to be a way that developers do this because I can't imagine a developer building something from scratch simply to use asp.net. That would be a waste of resources. Any guidance would be appreciated and I can stop pulling my hair out. Thanks!!!!
|
|
|
|
|
tinamiller wrote: how you use asp.net with an existing incomplete website.
You can't if it's not an ASP.NET site.
tinamiller wrote: because I can't imagine a developer building something from scratch simply to use asp.net
We do our research and choose the right language before we start. You're saying, if I write a book in English, surely there's a way to make it French, b/c no-one would rewrite it, right ?
If your site is just HTML, then you can put your HTML inside aspx pages, because all web frameworks use html, by definition. However, it's still a manual process if you want to use ASP.NET in those pages.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|