Click here to Skip to main content
15,886,026 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Application for creating vector objects Pin
Pete O'Hanlon2-Mar-20 2:59
mvePete O'Hanlon2-Mar-20 2:59 
GeneralRe: Application for creating vector objects Pin
MitchCZ2-Mar-20 3:31
MitchCZ2-Mar-20 3:31 
GeneralRe: Application for creating vector objects Pin
Pete O'Hanlon2-Mar-20 4:20
mvePete O'Hanlon2-Mar-20 4:20 
QuestionSome GridView controls are running empty rows. Any ideas to fix Pin
samflex25-Feb-20 7:57
samflex25-Feb-20 7:57 
SuggestionRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Richard MacCutchan25-Feb-20 8:51
mveRichard MacCutchan25-Feb-20 8:51 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
samflex25-Feb-20 9:03
samflex25-Feb-20 9:03 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Richard MacCutchan25-Feb-20 9:26
mveRichard MacCutchan25-Feb-20 9:26 
AnswerRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Mycroft Holmes25-Feb-20 11:35
professionalMycroft Holmes25-Feb-20 11:35 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
samflex25-Feb-20 17:20
samflex25-Feb-20 17:20 
SuggestionRe: Some GridView controls are running empty rows. Any ideas to fix Pin
phil.o25-Feb-20 20:19
professionalphil.o25-Feb-20 20:19 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Richard MacCutchan25-Feb-20 21:22
mveRichard MacCutchan25-Feb-20 21:22 
AnswerRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Blikkies26-Feb-20 1:19
professionalBlikkies26-Feb-20 1:19 
QuestionASP.NET + Multi Form using Textbox problem Pin
kerek224-Feb-20 21:41
kerek224-Feb-20 21:41 
SuggestionRe: ASP.NET + Multi Form using Textbox problem Pin
Richard MacCutchan24-Feb-20 23:16
mveRichard MacCutchan24-Feb-20 23:16 
QuestionWhen string in a cell has double quotes those appear in Excel after export. How do I remove them? Pin
Member 1140330424-Feb-20 10:19
Member 1140330424-Feb-20 10:19 
I need help to fix an issue where when data from web application is exported to Excel by clicking a button export to excel, if the data in a cell contains double quotes, that data should be displayed without the double quotes visible.

Also I want preceding zeros not to be removed e.g. 081 should not be exported to Excel as 81. This is why I have the line of code sw.Write("=""" & row(column).ToString().Trim() & """" & vbTab)

Previously I made a change to the application code in VB so that the output exports text fields with formulas (="") to force Excel to treat those values as a string. This has been working except some instances where the output actually displays the formula characters (="") within the cell as text, rather than as hidden formulas. It appears when a cell contains text with an actual double quotes that is when after export to Excel is done, those quotes appear in Excel. I need help to figure out if there is a way to suppress those.

For example. A cell with the following data Allows the user the abilities to Add, View, Modify and Delete Notes on the Notes Tab of the Case Record. "View" allows the user to view the Notes Tab of the Case Record.

When this is exported to Excel the data is displayed as follows ="Allows the user the abilities to Add, View, Modify and Delete Notes on the Notes Tab of the Case Record. "View" allows the user to view the Notes Tab of the Case Record. I do not want to quotes to appear in Excel.

On the other hand, a cell with the following data Maintain Victim Classification Types. when this is exported to Excel there are no visible quotes. It displays as Maintain Victim Classification Types.

Here is my VB code that needed changing

VB
Protected Sub WriteToExcelFile(dt As DataTable)
    'This method exports the resulting query datatable to an instance of Excel using StringWriter
    If Not dt Is Nothing Then
        Dim sw As New StringWriter()
        'Loop through the column names and output those first
        For Each datacol As DataColumn In dt.Columns
            sw.Write(datacol.ColumnName + vbTab)
        Next
        Dim row As DataRow
        'Loop through the datatable's rows
        For Each row In dt.Rows
            'Newline between the previous row and the next row
            sw.Write(vbNewLine)
            Dim column As New DataColumn()
            'Loop through each column and write the cell the the stringwriter
            For Each column In dt.Columns
                'If the cell isn't empty write it, else write an empty cell
                If Not row(column.ColumnName) Is Nothing Then
					sw.Write("=""" & row(column).ToString().Trim() & """" & vbTab)
                    Else
                        sw.Write(String.Empty + vbTab)
                    End If
                Next column
            Next row
            'create an instance of Excel and write the data
            Response.Clear()
            Response.ContentType = "application/vnd.ms-excel"
            Response.AddHeader("Content-Disposition", "attachment;filename=GridViewExport.xls")
            Response.Output.Write(sw.ToString())
            Response.Flush()
            System.Web.HttpContext.Current.Response.Flush()
            System.Web.HttpContext.Current.Response.SuppressContent = True
            System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest()
        End If
End Sub


modified 25-Feb-20 10:56am.

AnswerRe: When string in a cell has double quotes those appear in Excel after export. How do I remove them? Pin
Member 1140330424-Feb-20 11:26
Member 1140330424-Feb-20 11:26 
Rant[REPOST] When string in a cell has double quotes those appear in Excel after export. How do I remove them? Pin
Richard Deeming25-Feb-20 2:27
mveRichard Deeming25-Feb-20 2:27 
Questionreturning null value from populated selectlist with DB data Pin
ElenaRez21-Feb-20 21:11
ElenaRez21-Feb-20 21:11 
QuestionASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol18-Feb-20 8:32
Mou_kol18-Feb-20 8:32 
AnswerRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
jkirkerx19-Feb-20 9:15
professionaljkirkerx19-Feb-20 9:15 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol19-Feb-20 9:41
Mou_kol19-Feb-20 9:41 
AnswerRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
F-ES Sitecore19-Feb-20 23:01
professionalF-ES Sitecore19-Feb-20 23:01 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol21-Feb-20 22:36
Mou_kol21-Feb-20 22:36 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
F-ES Sitecore23-Feb-20 22:46
professionalF-ES Sitecore23-Feb-20 22:46 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
F-ES Sitecore23-Feb-20 22:52
professionalF-ES Sitecore23-Feb-20 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.