EXCEL±éÀú²¢Ð´Èëµ½XMLÖУ¨C#£© - .NET¼¼Êõ / C#
ÒòΪ²»ÖªµÀÈçºÎ¼ÓÈ븽¼þÎÒ¾ÍÊÖдEXCELÊý¾ÝÁË¡£
C# code:
A B C D E F G £¨´ËÀ¸Î»EXCELÖÐROWÐУ¬µÚÒ»ÐÐÊý×ÖÒàÈ»£©
1 ʵÀý±êÌâ
2 by name
3 ¿ÆÄ¿ ±¸註 ³É¼¨
4 Ó¢Óï 89
5 Êýѧ 80
6 ¼ÆËã»ú ¶þ¼¶ 89
7 Èý¼¶ 70
8
ʵÀý±êÌ⣺CDEºÏ²¢
by name£ºFGºÏ²¢
¿ÆÄ¿£ºABºÏ²¢
±¸註£ºCDºÏ²¢
³É¼¨£ºEFºÏ²¢
ÎÒÊÇÐÂÊÖ£¬ËùÒԺܶ඼²»¶®£¬Âé·³´ó¼ÒдÏêϸµã£¬×îºÃ´Ó½¨Á¢¹¤³Ì¿ªÊ¼½²Æð£¬ÈçÐèÒª½¨Á¢Ê²Ã´Îļþ£¬ÔÚÎļþÖÐÐèÒªÌí¼ÓÄÇЩÃüÃû¿Õ¼ä£¬È»ºóÔÙÊÇÔõô´ò¿ª²¢±£´æExcelÊý¾Ý£¬È»ºó±éÀúEXCEL²¢Ð´ÈëXMLÖÐ(ÉèÁ½¸ö½×²ã¾Í¿ÉÒÔ)£¬×îºó¾ÍÊÇÅöµ½Ò»Ð©ÎÊÌâÔõô´¦Àí£¬±ÈÈçÅöµ½Á½¸öºÏ²¢µÄµ¥Ôª¸ñÈçºÎץȡ²¢Ð´È룬עÒâµÄÊÂÏîµÈµÈ¡£
Óеã啰࣬µ«Ã»°ì·¨£¬ÎÒÏëѧһ´ÎºóÈ»ºó×Ô¼º¶à¶àÁ·Ï°£¬Ñ§µÄ¿ìһЩ¡£ÓÐÀÍÁË¡£¡£¡£
SELECT * into newtable
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=False;IMEX=1'";
DataSet ds= new DataSet();
using(OleDbConnection OleConn = new OleDbConnection(strConn))
{
OleConn.Open();
String sql = "SELECT * from [Sheet1$]";
OleDbDataAdapter OleDaExcel = new
Ïà¹ØÎÊ´ð£º
DataSetµ¼³öxml Åú´¦Àí(Ñ»·)µÃÔõô´¦Àí
XMLÎļþ
<A>
<B>
<C>
</C>
&nb ......
±¾ÈËÕýÔÚÓÃJava×öÒ»¸öC/S¼Ü¹¹µÄÏîÄ¿£¬
¿ÉÊÇÓÉÓÚÏîÄ¿±È½Ï´ó£¬Ç°ÆڶԼܹ¹µÄÉè¼ÆÓÈÆäÖØÒª£¬ÒòΪºóÆÚ¿ÉÄÜËæʱ»á¼Ó¸ö¹¦ÄÜ»òÕßÈ¥µôijЩ¹¦ÄÜ¡£
ËùÒÔÌصØÑ°ÇóÈçºÎÉè¼ÆC/SµÄ¼Ü¹¹Ê¹³ÌÐò¸ü¼ÓÃæÏò¶ÔÏó¸ü¼ÓÒ×ÓÚά ......
ÔÚ¸ùĿ¼/libÖдæ·ÅÒ»¸ölog.c£¬log.h£¬²¢ÓÃÏÂÃæµÄÓï¾ä£º
gcc -c log.c
ar crv liblog.a log.o
±àÒë³öÒ»¸öliblog.a¾²Ì¬¿â£¬È»ºóÔÚÎļþ¼Ð£º/testfileÖд´½¨Ò»¸ötest.cºÍtestc.c£¬test.cÖÐÒýÓÃÁËtestc.cÖж¨ÒåµÄ·½·¨ ......
ÏÖÔÚÓиöxmlÎļþÊÇ<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xm ......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎĶ¼¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......