Here is my C# code, Visual Studio 2015.
I would like to save those Excel cells to convert Text File.
For example, selecting values from AN1 from AN50, then save
"Range1.txt".
Thanks a lot.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
namespace WindowsFormsApplication4
{
static class Program
{
/// <summary>
[STAThread]
static void Main()
{
string testingExcel = @"V:\000.xlsx";
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Workbook xlWorkbook = xlApp.Workbooks.Open(testingExcel, Type.Missing, true);
_Worksheet xlWorksheet = (_Worksheet)xlWorkbook.Sheets[1];
//Range xlRange = xlWorksheet.UsedRange;
Range Range1 = xlWorksheet.get_Range("AN1","AN50");
foreach (Range a in Range1.Rows.Cells)
{
Console.WriteLine("Address: " + a.Address + " - Value: " + a.Value);
}
Range Range2 = xlWorksheet.get_Range("AO1", "AO50");
foreach (Range b in Range2.Rows.Cells)
{
Console.WriteLine("Address: " + b.Address + " - Value: " + b.Value);
}
xlWorkbook.Close();
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(xlWorkbook);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(xlApp);
}
}
}