想要用C#操作excel修改其中多列数据(由十六进制转为十进制)如何实现,求高手解答。
2012-04-17
展开全部
打开Ecxcl,然后循环表,写方法,将十六进制转为十进制最后保存
string excelName= ExcelFileUrl();//返回Excel的路径
string fileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + excelName;//保存Excle的文件路径
object missing = Missing.Value;
Microsoft.Office.Interop.Excel.Application appExcel = null;//实例Excel类
try
{
appExcel = new Microsoft.Office.Interop.Excel.Application();
appExcel.DisplayAlerts = false;//DisplayAlerts 属性设置成 False,就不会出现这种警告。
Microsoft.Office.Interop.Excel.Workbook workbook = appExcel.Workbooks.Open(fileName,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);//打开Excel
//Microsoft.Office.Interop.Excel.Workbooks workbooks = appExcel.Workbooks;//
//Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(missing);//工作簿
Microsoft.Office.Interop.Excel.Sheets sheets = workbook.Worksheets;//实例表格
Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets[1];//第一个表格
}
catch
{}
打开Excel
string excelName= ExcelFileUrl();//返回Excel的路径
string fileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + excelName;//保存Excle的文件路径
object missing = Missing.Value;
Microsoft.Office.Interop.Excel.Application appExcel = null;//实例Excel类
try
{
appExcel = new Microsoft.Office.Interop.Excel.Application();
appExcel.DisplayAlerts = false;//DisplayAlerts 属性设置成 False,就不会出现这种警告。
Microsoft.Office.Interop.Excel.Workbook workbook = appExcel.Workbooks.Open(fileName,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);//打开Excel
//Microsoft.Office.Interop.Excel.Workbooks workbooks = appExcel.Workbooks;//
//Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(missing);//工作簿
Microsoft.Office.Interop.Excel.Sheets sheets = workbook.Worksheets;//实例表格
Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets[1];//第一个表格
}
catch
{}
打开Excel
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询