Hallo hallo! I wanted to import an Excel Sheet into a datatable. After using this code
I was only able to import the data if the file was first loaded into excel and "Saved As" another file. If not, I was getting the error "External table is not in the expected format".
After lots and lots of searching I could find a solution so I opened the file with a text editor and although the extension was .xls, the file content was the following:
which seems like HTML to me.
I tried using the 'HTML Import' as the Extended Property (I found this somewhere mentioned) but I get 'Unspecified Error'.
Is there a way to do it? Has anybody experienced something like that before??
Thank you
Code:
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.Ace.12.0;Data Source=" & file & ";Extended Properties='Excel 12.0';")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Book1-2$]", MyConnection)
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
MyConnection.Close()After lots and lots of searching I could find a solution so I opened the file with a text editor and although the extension was .xls, the file content was the following:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Alpha Web Banking</title>
<script type="text/javascript">
function hideNonPrintableElementsAndPrint(obgID,printOption)
{
HtmlSource = window.opener.document.getElementById('_printablePageSection').innerHTML;
document.getElementById(obgID).innerHTML = HtmlSource;
//if ( document.getElementById('ctl00__contentPlaceHolder_ctl00__non_Printable_PlaceHolder') )
//{
// alert( document.getElementById('ctl00__contentPlaceHolder_ctl00__non_Printable_PlaceHolder').innerHTML );
// }
//for(i=0;i<=document.documentElement.childNodes.length-1;i++)
//{
// alert('i=' + i);
// for(j=0;j<=document.documentElement.childNodes[i].childNodes.length-1;j++)
// {
// alert('i j=' + i + ' ' + j + ' : ' + document.documentElement.childNodes[i].childNodes[j].innerHTML);
// }
//}
if (printOption == 'ExplicitSection')
{
if ( window.opener.document.getElementById('_explicitPrintableSection') )
{
HtmlSource = window.opener.document.getElementById('_explicitPrintableSection').innerHTML;
document.getElementById(obgID).innerHTML = HtmlSource;
}
}
window.print();
window.close();
}
</script>
</head>
<body onload="javascript: hideNonPrintableElementsAndPrint('_panel','');">
<form method="post" action="AWBSpreadSheetPrintablePage.aspx?service=statementsA400" id="_masterPrintableForm">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="gENCA/w8pvuWFyVqsZ8kT2pl5vN8csLTJKTaCFNCR9i9yl7Hs6JuKsfvFJLD+yg15C1aShtaQYZFKpVnwxc0lPq19Me3ADsn2hh077curNkNe+BIKVddafVQWew9XbXlY0jNjXaCX5RRWWGbBOlDN1SQuM0=" />
</div>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
</div>
<table class="GlobalTableSmall" cellspacing="0" cellpadding="0" width="645px" align="center" border="0">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="1px">
<img height="48px" alt="ALPHA BANK logo" src='https://secure.alpha.gr/e-services/images/img2.gif' width="174px" border="0"/>
</td>
<td align="right" width="99%" background='https://secure.alpha.gr/e-services/images/IMG11.gif'>
<img src='https://secure.alpha.gr/e-services/images/awbbottom.gif' height="11" width="179" border="0" alt="" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<div>
<div id="_panel">
</div>
<table cellpadding="5" cellspacing="0" border="0" width="100%">
<tr>
<td>
</td>
</tr>
<tr>
<td class="BodyHeader">ΞΞΉΞ½Ξ®ΟΞµΞΉΟ Ξ»ΞΏΞ³Ξ±ΟΞΉΞ±ΟΞΌΞΏΟ</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>Ξ£ΟΞΏΞΉΟΞµΞ―Ξ± ΟΞ·Ο : 07/06/2014 09:58</td>
</tr>
<tr id="_contentPlaceHolder__trSep1">
<td> </td>
</tr>
<tr id="_contentPlaceHolder__trHeader">
<td>
<table>
<tr>
<td class="FieldNameNormal" align="right">ΞΟΞΌΞΉΟΞΌΞ±:</td>
<td class="FieldValueNormal" align="left">EUR</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="_contentPlaceHolder__trSep2"> </td>
</tr>
<tr id="_contentPlaceHolder__trDetails">
<td>
<table>
<tr>
<td class="ExcelHeaderCellLeft">ΞΞΌ/Ξ½Ξ―Ξ±</td>
<td class="ExcelHeaderCellCenter">ΞΞΉΟολογία</td>
<td class="ExcelHeaderCellCenter">ΞΞ±ΟΞ¬ΟΟΞ·ΞΌΞ±</td>
<td class="ExcelHeaderCellCenter" colspan="2">Ξ*ΞΏΟΟ</td>
<td class="ExcelHeaderCellRight" colspan="2">ΞΞΉΞΊΟΟ Ο
ΟΟλοιΟΞΏ</td>
</tr>
<tr>
<td class="ExcelCellLeft">5/11/2012</td>
<td class="ExcelCellCenter">ΞΞ-ΞΞΞ¤ΞΞΞΣΠΣΠΞΞΞ¤ΞΣΤΞΞΞ</td>
<td class="ExcelCellCenter">540</td>
<td class="ExcelCellCenter">1.200,00</td>
<td class="ExcelCellCenter">Ξ*</td>
<td class="ExcelCellCenter">1.200,57</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">12/5/2014</td>
<td class="ExcelCellCenter">Ξ£Ξ-ΣΥΞΞΞΞΤΡΩΤΞΞΞ ΞΞΞΞ΅ΞΞ¦Ξ</td>
<td class="ExcelCellCenter">99</td>
<td class="ExcelCellCenter">24.945,47</td>
<td class="ExcelCellCenter">Ξ*</td>
<td class="ExcelCellCenter">26.146,04</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">12/5/2014</td>
<td class="ExcelCellCenter">Ξ£Ξ-ΣΥΞΞΞΞΤΡΩΤΞΞΞ ΞΞΞΞ΅ΞΞ¦Ξ</td>
<td class="ExcelCellCenter">99</td>
<td class="ExcelCellCenter">25.618,54</td>
<td class="ExcelCellCenter">Ξ§</td>
<td class="ExcelCellCenter">527,50</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">13/5/2014</td>
<td class="ExcelCellCenter">ΞΞ-Ξ*ΞΞΡΩΞΞ ΞΞΡΤΞΞ£ ΞΞΞΞ§ </td>
<td class="ExcelCellCenter">96</td>
<td class="ExcelCellCenter">300,00</td>
<td class="ExcelCellCenter">Ξ§</td>
<td class="ExcelCellCenter">227,50</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">14/5/2014</td>
<td class="ExcelCellCenter">ΞΞ-ΞΞΞΞΣΠΞΞΣΩ ALPHA WEB BANKING (INTERNET)</td>
<td class="ExcelCellCenter">96</td>
<td class="ExcelCellCenter">8,20</td>
<td class="ExcelCellCenter">Ξ*</td>
<td class="ExcelCellCenter">235,70</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">20/5/2014</td>
<td class="ExcelCellCenter">ΞΞ-ΞΞΞΞΣΠΞΞΣΩ ALPHA WEB BANKING (INTERNET)</td>
<td class="ExcelCellCenter">96</td>
<td class="ExcelCellCenter">286,40</td>
<td class="ExcelCellCenter">Ξ*</td>
<td class="ExcelCellCenter">522,10</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">20/5/2014</td>
<td class="ExcelCellCenter">ΞΞ-Ξ*ΞΞΡΩΞΞ ΞΞΡΤΞΞ£ ΞΞΞΞ§ </td>
<td class="ExcelCellCenter">96</td>
<td class="ExcelCellCenter">290,00</td>
<td class="ExcelCellCenter">Ξ§</td>
<td class="ExcelCellCenter">232,10</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">21/5/2014</td>
<td class="ExcelCellCenter">ΞΞ-Ξ*ΞΞΡΩΞΞ ΞΞΡΤΞΞ£ ΞΞΞΞ§ </td>
<td class="ExcelCellCenter">96</td>
<td class="ExcelCellCenter">70,00</td>
<td class="ExcelCellCenter">Ξ§</td>
<td class="ExcelCellCenter">162,10</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">21/5/2014</td>
<td class="ExcelCellCenter">ΞΞ-ΞΞΞΞΣΠΞΞΣΩ ALPHA WEB BANKING (INTERNET)</td>
<td class="ExcelCellCenter">96</td>
<td class="ExcelCellCenter">28,90</td>
<td class="ExcelCellCenter">Ξ§</td>
<td class="ExcelCellCenter">133,20</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">23/5/2014</td>
<td class="ExcelCellCenter">ΞΞ-ΞΞΞΞΣΠΞΞΣΩ ALPHA WEB BANKING (INTERNET)</td>
<td class="ExcelCellCenter">96</td>
<td class="ExcelCellCenter">15,10</td>
<td class="ExcelCellCenter">Ξ*</td>
<td class="ExcelCellCenter">148,30</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">28/5/2014</td>
<td class="ExcelCellCenter">ΞΞ-ΞΞΞΞΣΠΞΞΣΩ ALPHA WEB BANKING (INTERNET)</td>
<td class="ExcelCellCenter">96</td>
<td class="ExcelCellCenter">8,00</td>
<td class="ExcelCellCenter">Ξ§</td>
<td class="ExcelCellCenter">140,30</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLeft">5/6/2014</td>
<td class="ExcelCellCenter">ΞΞ-ΞΞΞΞΣΠΞΞΣΩ ALPHA WEB BANKING (INTERNET)</td>
<td class="ExcelCellCenter">96</td>
<td class="ExcelCellCenter">1.000,00</td>
<td class="ExcelCellCenter">Ξ*</td>
<td class="ExcelCellCenter">1.140,30</td>
<td class="ExcelCellRight">Ξ*</td>
</tr>
<tr>
<td class="ExcelCellLast"> </td>
<td class="ExcelCellLast"> </td>
<td class="ExcelCellLast"> </td>
<td class="ExcelCellLast"> </td>
<td class="ExcelCellLast"> </td>
<td class="ExcelCellLast"> </td>
<td class="ExcelCellLast"> </td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<table border="0" cellspacing="2" cellpadding="0" width="100%">
<tr>
<td align="left" class="FieldValueSmall" style="height: 16px;width:385px;">
</td>
<td class="FieldValueExtraSmall" align="right">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>I tried using the 'HTML Import' as the Extended Property (I found this somewhere mentioned) but I get 'Unspecified Error'.
Is there a way to do it? Has anybody experienced something like that before??
Thank you



.jpeg)


