开发者

C# interop.excel workbooks.opentext method fieldinfo doesn't work

开发者 https://www.devze.com 2023-04-11 07:16 出处:网络
Fieldinfo can read text file in different format, but it seems not to be working for me. I tried what is on http://msd开发者_开发知识库n.microsoft.com/en-us/library/bb223513.aspx.

Fieldinfo can read text file in different format, but it seems not to be working for me. I tried what is on http://msd开发者_开发知识库n.microsoft.com/en-us/library/bb223513.aspx.

object fieldInfo = new int[21, 2] {{ 1, 2 },{ 2, 2 },{ 3, 2 }, { 4, 2 },{ 5, 2 },{ 6, 2 },{ 7, 2 },{ 8, 1 },{ 9, 1 },{ 10, 1 },
            { 11, 1 },{ 12, 1 },{ 13, 1},{ 14, 2 },{ 15, 1},{ 16, 1 },{17, 2},{ 18, 2 },{ 19, 2 },{ 20, 2 }, { 21, 2 }

                        };
        xlApp.Workbooks.OpenText(myZdrive + @"\CI_System\Source_Files\" + myPosFile, XlPlatform.xlWindows, 1,
                                 XlTextParsingType.xlDelimited,
                                XlTextQualifier.xlTextQualifierNone, false, true, false, false, false, false, false, fieldInfo);    


Don't use the Excel interop. Use the OpenXml SDK.

You can download it here:
http://www.microsoft.com/download/en/details.aspx?id=5124

Here is an article explaining how to use it:
http://msdn.microsoft.com/en-us/library/dd469465%28v=office.12%29.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消