Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 8 of 8

How to export data to excel using C#

This is a discussion on How to export data to excel using C# within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi I'm trying to using the function export to excel in C# programming but I don't know how to proceed. ...

  1. #1
    xortam is offline Junior Member White Belt
    Join Date
    Feb 2005
    Posts
    1

    How to export data to excel using C#

    Hi
    I'm trying to using the function export to excel in C# programming but I don't know how to proceed. If someone could help me it would be very usefull
    Thanks

  2. #2
    Roshdy25 is offline Junior Member White Belt
    Join Date
    Oct 2008
    Posts
    1

    Re: How to export data to excel using C#

    Code:
    protectedvoid IM_ToExcel_Click(object sender, ImageClickEventArgs e)
    {
    try
    {
    DataTable AllParticipant = ((DataView)AllParticipants().Select(newDataSourceSelectArguments())).Table;
    DataTable AllParticipantdT = newDataTable(); int RIndex = 0;
    foreach (DataRow ParticipantRow in AllParticipant.Rows)
    {
    DataRow ParticipantdTRow = AllParticipantdT.NewRow();
    foreach (DataColumn ParticipantCoulmn in AllParticipant.Columns)
    {
    if (RIndex == 0)
    {
    if (ParticipantCoulmn.DataType == typeof(bool))
    AllParticipantdT.Columns.Add(ParticipantCoulmn.ColumnName, typeof(string));
    elseif (ParticipantCoulmn.ColumnName == "Approve")
    AllParticipantdT.Columns.Add(ParticipantCoulmn.ColumnName, typeof(string));
    else
    AllParticipantdT.Columns.Add(ParticipantCoulmn.ColumnName, ParticipantCoulmn.DataType);
    }
    if (ParticipantCoulmn.DataType == typeof(bool))
    {
    if (ParticipantCoulmn.ColumnName == "Reg_Gender")
    {
    if (ParticipantRow["Reg_Gender"].ToString() == bool.TrueString)
    {
    ParticipantdTRow["Reg_Gender"] = "Male";
    }
    else
    {
    ParticipantdTRow["Reg_Gender"] = "Female";
    }
    }
    elseif (ParticipantCoulmn.ColumnName == "Kimedar")
    {
    if (ParticipantRow["Kimedar"].ToString() == bool.TrueString)
    {
    ParticipantdTRow["Kimedar"] = "Through Kimedar";
    }
    else
    {
    ParticipantdTRow["Kimedar"] = "";
    }
    }
    }
    else
    {
    if (ParticipantCoulmn.ColumnName == "Approve")
    {
    if (ParticipantRow["Approve"].ToString() == "0")
    {
    ParticipantdTRow["Approve"] = "New";
    }
    elseif (ParticipantRow["Approve"].ToString() == "1")
    {
    ParticipantdTRow["Approve"] = "Approved";
    }
    else
    {
    ParticipantdTRow["Approve"] = "Rejected";
    }
    }
    else
    {
    ParticipantdTRow[ParticipantCoulmn.ColumnName.ToString()] = ParticipantRow[ParticipantCoulmn.ColumnName];
    }
    }
    }
    AllParticipantdT.Rows.Add(ParticipantdTRow);
    RIndex++;
    }
    int[] iColumns = { 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 };
    RKLib.ExportData.Export objExport = new RKLib.ExportData.Export();
    objExport.ExportDetails(AllParticipantdT, iColumns, Export.ExportFormat.Excel, "Registered.xls");
    }
    catch { return; }
    }
    

    I hope this help you
    Its work with me
    Last edited by Eric Frost; 02-15-2012 at 08:58 AM.

  3. #3
    filip is offline Junior Member White Belt
    Join Date
    Jul 2009
    Posts
    3

    Re: How to export data to excel using C#

    Hi xortam,

    easiest and fastest way to use Excel in C# is by some 3rd party component. You can try GemBox .NET Excel component which comes in free version with limit of 150 rows.

    Here you can see why GemBox spreadsheet component is much better then Excel Automation.

    Filip
    GemBox Software - easier & faster way to deal with Excel then Excel Automation

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: How to export data to excel using C#

    Excel automation isn't hard though - it is usually easier than using MapPoint's COM interface for a beginner, because there are more published examples.

    Also Excel has other approaches such as ADO.NET if you felt that way inclined.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  5. #5
    thorus is offline Junior Member White Belt
    Join Date
    Aug 2009
    Posts
    1

    Re: How to export data to excel using C#

    There are also real-time methods of getting data into Excel, DDE and RTD for instance. They are fairly simple technologies and allow for dynamic updates in Excel, RTD works in a cell so normal calculations are possible. RTD allows for very rapid updates if the data is changing frequently.

    Have a look at this website for info:
    realtimeconnect.thorusproductions.com/RTD---Real-Time-Data.php

  6. #6
    Lina99 is offline Junior Member White Belt
    Join Date
    Feb 2011
    Posts
    1

    Re: How to export data to excel using C#

    I know one nice article about exporting data. It introduces a good way to export data to excel and other format files. I think you can read this article
    (Data Export from Database to Excel, PDF and Word for .NET without Automation and Acrobat Reader - CodeProject) for getting answer.

  7. #7
    Summi is offline Junior Member White Belt
    Join Date
    Feb 2012
    Posts
    1

    Re: How to export data to excel using C#

    Hello,

    Export Data from GridView to Excel, Word, HTML with C#
    Method in this article may be helpful for you.

  8. #8
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: How to export data to excel using C#

    That code above looks so complicated. Just thought I should point out -- MapPoint now has an ExportToExcel method.

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Export of Pushpin Data to Excel
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 06-25-2008, 10:13 AM
  2. What it is the command to export data in excel format ?
    By Elbarto in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-15-2006, 05:38 AM
  3. Export Map Point Data to Excel
    By Anonymous in forum Wish List
    Replies: 0
    Last Post: 12-09-2004, 04:30 PM
  4. how to export the data of an Excel table on a chart mappoint
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 02-17-2004, 05:37 AM
  5. Export to excel
    By Dazzer in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-23-2003, 05:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25