工作中为了方便,经常使用excel表进行编辑,然后转换为程序用的csv和txt文件。
用c#做了个小工具,生成的exe文件放到需要转换的excel文件目录,可以实在自动读取该目录下的所有xlsx文件,并在该目录下创建csv和txt两个文件夹,用来存放转换之后的csv和txt文件。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;
//添加引用--》引用管理器--》COM类型库中找到Microsoft Excel xx Object Library
//xx看自己的excel版本
using Microsoft.Office.Interop.Excel;
using System.IO;
using System.Reflection;
using System.Diagnostics;
//功能目标,将当前目录下的所有xlsx的EXCEL文件导出为csv和txt格式
namespace ExcelTools
{
class Program
{
private static void QuitExcel()
{
Process[] excels = Process.GetProcessesByName("EXCEL");
foreach (var item in excels)
{
item.Kill();
}
}
static void Main(string[] args)
{
QuitExc