Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Urgent Pls!!!!! Problem while exporting data to excel sheet in asp

Reply
Thread Tools

Urgent Pls!!!!! Problem while exporting data to excel sheet in asp

 
 
=?Utf-8?B?U2lsZWVzaA==?=
Guest
Posts: n/a
 
      11-08-2004
Hi

I am exporting data from database to an excel sheet. Some of the data have
"+/-" .For example: "120+/-10"

When i connect to the local database and export the data, it does export
correctly say "120+/-10" . But when i connect to production database, it does
not export data correctly say "120 10" .

Does any have idea of what is going wrong here. Ihave attached test file
also.
Pls Help



here is test.aspx file
----------------------

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb"
Inherits="TycoMIS.test"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>
test
</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="resources/newClass.css" type="text/css" rel="STYLESHEET">
</HEAD>
<body class="pagebackground" leftMargin="1" topMargin="1" rightMargin="2">
<form id="Form2" method="post" runat="server">
<table id="TestTable" runat=server cellSpacing="0" cellPadding="0"
width="100%" border="0">
</table>
</form>
</body>
</HTML>

here is test.aspx.vb file
-------------------------

Public Class test
Inherits System.Web.UI.Page
Protected WithEvents TestTable As System.Web.UI.HtmlControls.HtmlTable
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Response.Buffer = True
Response.AddHeader("Content-Disposition",
"attachment;filename=test.xls")
Response.ContentType = "application/vnd.ms-excel"
'
Dim i As Integer
For i = 0 To 9
Dim Ptr As New HtmlTableRow()
addData(Ptr, "70+/-2")
TestTable.Controls.AddAt(i, Ptr)
Next
'
End Sub
'
Public Sub addData(ByRef Ptr As HtmlTableRow, ByVal txtStr As String)
Dim Ptc1 As New HtmlTableCell()
'
Ptc1.InnerText = txtStr
Ptr.Controls.Add(Ptc1)
'
End Sub
'
End Class


Now if we run this file it should open excel file and write "70+/-2" in 10
lines. but it is writing "702" in 10 lines.

if i comment following 3 lines in page_load events then it is displaying
"70+/-2" in 10 lines on browser.

Response.Buffer = True
Response.AddHeader("Content-Disposition",
"attachment;filename=test.xls")
Response.ContentType = "application/vnd.ms-excel"

please help me.
 
Reply With Quote
 
 
 
 
Jim Corey
Guest
Posts: n/a
 
      11-08-2004

Sileesh,

Try adding hard-coded quotation marks around the strings.
This can prevent excel from formatting the data.

I don't have any code in front on me, but if I recall correctly, sending
<td>"4.5"</td>
meant excel would treat this as a string (the quotes would not be
displayed), whereas
<td>4.5</td>
meant excel would treat it as a number.

Maybe this would help in your situation.

Jim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Stored procedure results to the Excel Sheet using Java AD1234 Java 5 03-28-2008 09:28 AM
change the sheet name while exporting datagrid data to excel =?Utf-8?B?U3JpZGhhcg==?= ASP .Net 0 11-09-2006 02:37 PM
CPU usage 99% (aspnet_wp.exe) while importing excel sheet Vivek ASP .Net 1 12-16-2004 03:23 PM
Urgent!!!!! Problem while exporting data to excel sheet in ap.net =?Utf-8?B?U2lsZWVzaA==?= ASP .Net 4 11-05-2004 10:57 PM
Exporting Datagrid's data to an Excel Sheet. http://www.visual-basic-data-mining.net/forum ASP .Net 1 10-25-2004 10:24 PM



Advertisments