解析Excel文件,读一小区小区、文件、Excel

2023-09-04 06:07:23 作者:用笑掩饰悲伤

我有一个excel文件。我已经上传截图。我需要写一个.NET应用程序(控制台应用程序)来解析excel文件。你可以看到标题为函数名的小区。我的.NET应用程序应该找到特定的细胞和读取该列中的内容,如模板,InstanceFromTemplate,任务等。如果它读取任务,它应该调用的CreateTask功能类似任务();如果它读取InstanceFromTemplate,它应该调用InstanceFromTemplate功能类似TaskInstanceFromTemplate();

我已经写了code为这些功能。我只需要帮助就如何解析excel表,去那个特定的列,读取包含列在函数名的细胞,并调用相应的函数。任何帮助将是AP preciated。

算法就像

在打开的Excel文件 搜索标题单元格题为功能名称 读取头单元格下的第一个单元格 如果第一个单元格读取,调用函数($ C $下GetAllTemplate功能已经存在)只需要调用它AFTE发现它 如果第二个单元格,通话功能。 在头细胞功能的名称在最后一个单元格为止。因此,退出 解决方案

根据你正在努力做的,你真的应该使用LINQ Ecxel插件什么的描述,我认为它简单的方法来解决你的问题。

HTTP://$c$c.google.com/p/linqtoexcel/

如何解密Excel文档

I got an excel file. I have uploaded the screenshot. I need to write a .NET application (console application) to parse the excel file. You can see a cell titled "Function Name". My .NET app should find that particular cell and read the contents in that column such as Template, InstanceFromTemplate, Task and so on. If it reads Task, it should call CreateTask function like Task(); If it reads InstanceFromTemplate, it should call InstanceFromTemplate function like TaskInstanceFromTemplate();

I have written code for those functions. I only need help on how to parse the excel sheet, go to that particular column, read the cells containing function names under that column and call that appropriate function. Any help would be appreciated.

Algorithm is like

open excel file search for a header cell titled Function Name Read the first cell under the header cell If the first cell reads , call function (code for GetAllTemplate function is already there) Only need to call it afte finding it If the second cell , call function. Last cell under the header cell Function Name is reached. So, exit

解决方案

Based on the Description on what you are trying to do you should really use LINQ to Ecxel plugin I think it simple way to solve your problem

http://code.google.com/p/linqtoexcel/