Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

maliary

@maliary
About
Posts
11
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Escaping Quotes
    M maliary

    Here is the complete link : http://www.codeproject.com/KB/aspnet/ExportClassLibrary.aspx[^]

    C# question help

  • Exporting Datatable to Excel
    M maliary

    Hi, Who here has used or knows about code that exports a datatable to excel, that handles quotes ". Try any. I'll appreciate your help.

    Let's do this !

    C# help

  • Escaping Quotes
    M maliary

    Ok, I am getting data from a datatable and exporting it to an excel sheet. I was using the RKLib.Export library, however this doesn't handle " quotes in the field values. It displays unintelligible data. So I decided to use the function I am asking about to clean out the datatable before exporting it. By the way, do you know where I would get code to export data to excel which handles quotes ?

    Let's do this !

    C# question help

  • Escaping Quotes
    M maliary

    Thanks for that, I have it already. But how do I apply this to all the elements in the table ?

    Let's do this !

    C# question help

  • Escaping Quotes
    M maliary

    Hello, Ok, we've gone round and round on this, so let me place an open question. I have a data table where some field values have this ". e.g. Nail 4". I need to replace this with \" as they are bringing error on my excel output. How can I access each field value and replace the " with \" ? Please help me, I'd really appreciate your help.

    Let's do this !

    C# question help

  • Accessing fields in a datatable
    M maliary

    Hi, I have done that, and also placing the Row.Clear before the rows, but I still get the error: input array is longer than the number of columns in this table error ? Where should I have it ?

                for (int j = 0; j < dpExport.Rows.Count; j++)
                {
                     Row.Clear();
    
                    for (int i = 0; i < dpExport.Columns.Count; i++)
                    {
                        
                        if (!Convert.IsDBNull(dpExport.Rows\[j\]\[i\].ToString()))
                        {
                            
                            data = dpExport.Rows\[j\]\[i\].ToString();
                            data = data.Replace("\\"", "\\"");
                            Row.Add(data.ToString());
                        }
    
                    }
                    dtExport.Rows.Add(Row.ToArray());
                }
    

    Let's do this !

    C# help

  • Accessing fields in a datatable
    M maliary

    This is the definition, Arraylist Rowz = new Arraylist () Its an array list

    Let's do this !

    C# help

  • Accessing fields in a datatable
    M maliary

    I changed it to this:

    for (int j = 0; j < dtExport.Rows.Count; j++)
    {

                    for (int i = 0; i < dtExport.Columns.Count; i++)
                    {
                        if (!Convert.IsDBNull(data = dtExport.Rows\[j\]\[i\].ToString()))
                        {
                            data = dtExport.Rows\[j\]\[i\].ToString();
    
                            data = data.Replace("\\"", "\\"");
                            RowZ.Add(data.ToString());
                        }
    
                    }
    dtExport.Rows.Add(RowZ.ToArray());
    
                   
                }
    

    but now I get this error System.ArgumentException:input array is longer than the number of columns in the table

    Let's do this !

    C# help

  • Accessing fields in a datatable
    M maliary

    This, which comes from a diffrent part of the code works

    foreach (DataRow dr in TheDataTable.Rows)
    {
    for (int i = 0; i < iColCount; i++)
    {
    if (!Convert.IsDBNull(dr[i]))
    {
    string data = dr[i].ToString();
    data = data.Replace("\"","\"");
    sw.Write(data);
    }
    if (i < iColCount - 1)
    {
    sw.Write(separator);
    }
    }
    sw.Write(sw.NewLine);
    }

    the diffrence with the other one is that, I want to put the elements back into a datatable, for other processing. I how do I make the change of the field values, then move the values into a data table again ?

    Let's do this !

    C# help

  • Accessing fields in a datatable
    M maliary

    Hi, I have this code for looping through the fields in a data table and replace some characters in the fields. I am trying to access the fields in the datatable. Its giving this error : System.InvalidOperationException: Collection was modified; enumeration operation might not execute. Could you help me through this, I'd really appreciate it. foreach (DataRow dr in dtExport.Rows) { for (int i = 0; i < dtExport.Columns.Count; i++) { if (!Convert.IsDBNull(dr[i])) { data = dr[i].ToString(); data = data.Replace("\"", "\""); RowZ.Add(data.ToString()); } } dtExport.Rows.Add(RowZ.ToArray()); }

    Let's do this !

    modified on Thursday, August 14, 2008 10:27 AM

    C# help

  • Escaping Quotes
    M maliary

    Hi, I have values in my database that have quotes e.g Spanner 2",Tyre 12" I am working on escaping them so that the output to a CSV file is legible. Currently I have

    data = data.Replace("\"","\\\"");

    Which is not working because the \" is not there. Instead I have " without the slash. How can I escape them ?

    Let's do this !

    C# question database
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups