Author Topic: Simply writing an array to an excel file  (Read 2551 times)

0 Members and 1 Guest are viewing this topic.

ekoneo

  • Newt
  • Posts: 66
Simply writing an array to an excel file
« on: November 21, 2015, 10:43:18 AM »
Hi all,

I have a class page including an array and I have a form including a button. When I pres the button in the form an excel file ll be created and the array ll write in this excel file. I downloaded Excel Library.

Anobody can help me with basic sample?

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: Simply writing an array to an excel file
« Reply #1 on: November 21, 2015, 04:33:13 PM »
Check out the last no below and once you have some code posted we can look at then we can help you better.

http://www.theswamp.org/index.php?topic=31867.0
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

ekoneo

  • Newt
  • Posts: 66
Re: Simply writing an array to an excel file
« Reply #2 on: November 23, 2015, 04:55:57 AM »
Thanks Keith,

My simple work is atached to this message.

My class sheet's code is:
Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;

using Autodesk.Civil.ApplicationServices;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.Civil.DatabaseServices;
using Autodesk.Civil.Settings;
using Autodesk.Civil.Runtime;
using Microsoft.Office.Interop.Excel;
using Autodesk.AutoCAD.Runtime;

namespace ClassLibrary9
{
    public class Class1
    {

        public class Commands
        {
            [CommandMethod("WriteToExcel")]
            public void Test()
            {
                String myString = "E,X,E,R,C,I,S,E";
                Array myArray = myString.Split();

                System.Windows.Forms.Application.EnableVisualStyles();
                System.Windows.Forms.Application.Run(new Form1());
            }
        }
    }
}

Form1's code is:

Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ClassLibrary9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Write function to writing myArray to an excel file.
        }
    }
}