Excel分隔不起作用 [英] Excel delimiting not working

查看:66
本文介绍了Excel分隔不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在代码中使用了excel互操作性,并且我想阅读以下分隔的excel数据.

Hi All,

I am using excel interoperability in my code and i want to read the below delimited excel data.

MAS|201012211616360001|Q-0263014640218 067 0423|LIMITED TOO|SS SOLID POLO||6110202075|100% COTTON####|||Q086|CASUAL TOPS CUT SEWN S|CH|CHILDREN|CUT SEWN|CASUAL TOPS|0423|067|0263014640218|59024316||||||||||N|||1|EA|1|0|1|1|CM|0|KG


代码如下



The code is as follow


string path = txtFile.Text;
                DirectoryInfo dir = new DirectoryInfo(path);
                FileInfo[] FileList = dir.GetFiles("*.*", SearchOption.AllDirectories);
                foreach (FileInfo FI in FileList)
                {
                    using (SqlConnection Connection = ConnectionManager.GetConnection())
                    {
                        Microsoft.Office.Interop.Excel.Application ExcelObj = new Microsoft.Office.Interop.Excel.Application();
                        Microsoft.Office.Interop.Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(FI.FullName, 0, true, 1, "","",false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "|", true, false, 0, true,false, false);
                        Microsoft.Office.Interop.Excel.Sheets sheets = theWorkbook.Worksheets;
                        Microsoft.Office.Interop.Excel.Worksheet workSheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets.get_Item(1);
                        int rowIndex = 1;
                        int colIndex1 = 1;
                        int index = 0;
                    a:  while (((Microsoft.Office.Interop.Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2 != null)
                        {


此时,value2将显示整个行,其不基于"|"
进行定界
我快要疯了...前几天工作还不错...我不知道发生了什么
请帮助我使用Microsoft.Office.Interop.Excel 12.0


At this point the value2 is showing the entire row, its not delimiting based on "|"

I am going crazy...it was working fine somedays ago...I donno what''s happening
Please help I am using Microsoft.Office.Interop.Excel 12.0

推荐答案

我几周前回答了这个问题,并且您确认它有所帮助.

Excel互操作性定界选项不起作用 [ ^ ]
I answered this a few weeks ago and you confirmed it helped.

Excel interoperability delimiting option not working[^]


这篇关于Excel分隔不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆