Click here to Skip to main content
15,174,232 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Mycroft Holmes25-Feb-20 12:35
professionalMycroft Holmes25-Feb-20 12:35 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
samflex25-Feb-20 18:20
Membersamflex25-Feb-20 18:20 
SuggestionRe: Some GridView controls are running empty rows. Any ideas to fix Pin
phil.o25-Feb-20 21:19
mvephil.o25-Feb-20 21:19 
GeneralRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Richard MacCutchan25-Feb-20 22:22
mveRichard MacCutchan25-Feb-20 22:22 
AnswerRe: Some GridView controls are running empty rows. Any ideas to fix Pin
Blikkies26-Feb-20 2:19
professionalBlikkies26-Feb-20 2:19 
QuestionASP.NET + Multi Form using Textbox problem Pin
kerek224-Feb-20 22:41
Memberkerek224-Feb-20 22:41 
SuggestionRe: ASP.NET + Multi Form using Textbox problem Pin
Richard MacCutchan25-Feb-20 0:16
mveRichard MacCutchan25-Feb-20 0: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 11:19
MemberMember 1140330424-Feb-20 11: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 12:26
MemberMember 1140330424-Feb-20 12: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 3:27
mveRichard Deeming25-Feb-20 3:27 
Questionreturning null value from populated selectlist with DB data Pin
ElenaRez21-Feb-20 22:11
MemberElenaRez21-Feb-20 22:11 
QuestionASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol18-Feb-20 9:32
MemberMou_kol18-Feb-20 9:32 
AnswerRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
jkirkerx19-Feb-20 10:15
professionaljkirkerx19-Feb-20 10:15 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol19-Feb-20 10:41
MemberMou_kol19-Feb-20 10:41 
AnswerRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
F-ES Sitecore20-Feb-20 0:01
mveF-ES Sitecore20-Feb-20 0:01 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol21-Feb-20 23:36
MemberMou_kol21-Feb-20 23:36 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
F-ES Sitecore23-Feb-20 23:46
mveF-ES Sitecore23-Feb-20 23:46 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
F-ES Sitecore23-Feb-20 23:52
mveF-ES Sitecore23-Feb-20 23:52 
AnswerRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Richard Deeming20-Feb-20 1:23
mveRichard Deeming20-Feb-20 1:23 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol21-Feb-20 23:40
MemberMou_kol21-Feb-20 23:40 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Bohdan Stupak23-Feb-20 1:19
professionalBohdan Stupak23-Feb-20 1:19 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Richard Deeming23-Feb-20 22:16
mveRichard Deeming23-Feb-20 22:16 
QuestionUpdating two related tables in asp.net core Pin
ElenaRez16-Feb-20 19:35
MemberElenaRez16-Feb-20 19:35 
QuestionBinding combox in gridview with selected value of another comboBox Pin
BikerMonkey14-Feb-20 10:01
professionalBikerMonkey14-Feb-20 10:01 
QuestionHow to get a field's value from a linq query Pin
ElenaRez12-Feb-20 4:09
MemberElenaRez12-Feb-20 4:09 

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.