string path = "c://date//xyu.txt";
StreamReader sr = new StreamReader(path);
string strLine = sr.ReadLine();
int rowNum = 1;
object missing = System.Reflection.Missing.Value;
ApplicationClass app = new ApplicationClass();
app.Application.Workbooks.Add(true);
Workbook book = (Workbook)app.ActiveWorkbook;
Worksheet sheet = (Worksheet)book.ActiveSheet;
while (!string.IsNullOrEmpty(strLine))
{
string[] tempArr;
tempArr = strLine.Split(',');
for (int k = 1; k <= tempArr.Length; k++)
{
sheet.Cells[rowNum, k] = tempArr[k - 1];
}
strLine = sr.ReadLine();
rowNum++;
}
//保存excel文件
book.SaveCopyAs("D://source.xls");
//关闭文件
book.Close(false, missing, missing);
//退出excel
app.Quit();
MessageBox.Show("转化成功!");
string path = "c://date//xyu.txt";
StreamReader sr = new StreamReader(path);
string strLine = sr.ReadLine();
int rowNum = 1;
object missing = System.Reflection.Missing.Value;
ApplicationClass app = new ApplicationClass();
app.Application.Workbooks.Add(true);
Workbook book = (Workbook)app.ActiveWorkbook;
Worksheet sheet = (Worksheet)book.ActiveSheet;
Range r = sheet.get_Range("A1", "C1");
//获取行数
object[,] objectData = new object[65535, 3];
while (!string.IsNullOrEmpty(strLine))
{
string[] tempArr;
tempArr = strLine.Split(',');
for (int k = 1; k <= tempArr.Length; k++)
{
objectData[rowNum-1, k-1] = tempArr[k - 1];
}
strLine = sr.ReadLine();
rowNum++;
}
r = r.get_Resize(65535, 3);
r.Value2 = objectData;
r.EntireColumn.AutoFit();
//保存excel文件
book.SaveCopyAs("D://source.xls");
//关闭文件
book.Close(false, missing, missing);
//退出excel
app.Quit();
MessageBox.Show("转化成功!");
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有