导出到Excel的gridview无法导入 [英] exported gridview to excel cannot be imported

查看:97
本文介绍了导出到Excel的gridview无法导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将gridview导出到exl时,它工作正常.当我尝试将相同的导出的gridview导入到exl时,我可以导入".显示错误外部表不是以expeted格式显示".请帮助我............

when i export gridview to exl, it is working fine. when i try to import the same exported gridview to exl, i can'' import.The error "external table is not in the expeted format" is showing. plese help me............

推荐答案

"External table is not in the expected format."通常在尝试使用带有以下内容的连接字符串的Excel 2007文件时发生使用: Microsoft.Jet.OLEDB.4.0 和Extended Properties = Excel 8.0

尝试以下连接字符串:

"External table is not in the expected format." typically occurs when trying to use an Excel 2007 file with a connection string that uses: Microsoft.Jet.OLEDB.4.0 and Extended Properties=Excel 8.0

try these connection string:

public static string path = @"C:\src\RedirectApplication\RedirectApplication\301s.xlsx";

public static string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";



希望对您有所帮助:)



hope it helps :)




尝试跟随

Hi

Try FOllowing

DataSet ds = new DataSet();

   String strConn = @"Provider = Microsoft.ACE.OLEDB.12.0;" + @"Data Source=C:\" +
                    MyFile.FileName + @";Extended Properties=''Excel 12.0;HDR=Yes;''";
   OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [Sheet1


", strConn); da.Fill(ds); GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind();
", strConn); da.Fill(ds); GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind();




或通过以下链接

CodeProject常见问题系列1:ASP.NET GridView [




or go through following link

CodeProject Frequently Asked Questions Series 1: The ASP.NET GridView[^]


这篇关于导出到Excel的gridview无法导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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