tag:blogger.com,1999:blog-84076737523710911252023-06-21T09:47:42.971+05:30Techie To LearnLearning the TechnologyAnonymoushttp://www.blogger.com/profile/04035027374716656450noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-8407673752371091125.post-27802082588818602592012-09-20T13:17:00.001+05:302012-09-20T13:17:57.491+05:30Using jQuery allowing Only Alphanumeric Characters in a Textbox <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Calibri;">Requirement <o:p></o:p></span></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">Need to
restrict the users by entering other than Alphanumeric Characters, if any user
enters Non- Alphanumeric Characters then need to trim those Characters and display
a message beside the respective textbox saying only Alphanumeric Characters are
allowed…<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><o:p><span style="font-family: Calibri;"> </span></o:p></b><b style="mso-bidi-font-weight: normal;"><span style="font-family: Calibri;">Solution:<o:p></o:p></span></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">We have many
solutions but using jQuery is the best way to achieve, with this we can use
more flexible and reliable Regular expression technology with jQuery to achieve
the above requirement.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><i style="mso-bidi-font-style: normal;"><o:p><span style="font-family: Calibri;"> </span></o:p></i></b><b style="mso-bidi-font-weight: normal;"><i style="mso-bidi-font-style: normal;"><span style="font-family: Calibri;">Script Code:<o:p></o:p></span></i></b></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="mso-spacerun: yes;"><span style="font-family: Calibri;"> </span></span><span style="font-family: Consolas; font-size: 9.5pt;">$(<span style="color: blue;">function</span> () {<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>$(<span style="color: maroon;">"#span_txtFirstName"</span>).hide();<o:p></o:p></span></div>
<br />
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>$(<span style="color: maroon;">"[id*='txtFirstName']"</span>).keyup(<span style="color: blue;">function</span> () {<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>$(<span style="color: maroon;">"#span_txtFirstName"</span>).hide();<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">if</span> (<span style="color: blue;">this</span>.value.match(/[^a-zA-Z0-9
]/g)) {<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">this</span>.value = <span style="color: blue;">this</span>.value.replace(/[^a-zA-Z0-9
]/g, <span style="color: maroon;">''</span>);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>$(<span style="color: maroon;">"#span_txtFirstName"</span>).toggle(500);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>});<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
</div>
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<b style="mso-bidi-font-weight: normal;"><i style="mso-bidi-font-style: normal;"><span style="font-family: Calibri;">HTML Code:<o:p></o:p></span></i></b></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">asp</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">:</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">TextBox</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">ID</span><span style="color: blue;">="txtFirstName"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Width</span><span style="color: blue;">="200px"</span> <span style="color: red;">CssClass</span><span style="color: blue;">="styled_input"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span><span style="color: blue;">></span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">span</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">id</span><span style="color: blue;">="span_txtFirstName"</span> <span style="color: red;">class</span><span style="color: blue;">="RegistrationNumericDiv"></span>oops! Only
AlphaNumberic Charecters are Accepted.<span style="color: blue;"></</span><span style="color: maroon;">span</span><span style="color: blue;">><o:p></o:p></span></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Calibri;">Explanation:<o:p></o:p></span></b></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">In the above
HTML Code is the normal code as I used asp.Net TextBox control to present this
demo, but we can use any technology here as our browser parser can understand
only HTML tags so every technology has their own parser to parse their
respective language code to HTML code. Next line we have a SPAN tag which is
used to hold the message to the user whenever user types a non-alphanumeric character
in the respective textbox and this SPAN tag hide/show will be handled in the
given jQuery code itself.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">As we can see we use the regular expression to validate each
character enter by the user and if anything wrong we replace those character(s)
with empty string (‘’) and we show the message by toggling the <span style="mso-spacerun: yes;"> </span>SPAN tag..<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">That’s it we are done with our requirement </span><span style="font-family: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">J</span></span><o:p></o:p></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">Thank you<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">Happy Coding
</span><span style="font-family: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">J</span></span><o:p></o:p></div>
</div>
Anonymoushttp://www.blogger.com/profile/04035027374716656450noreply@blogger.com0tag:blogger.com,1999:blog-8407673752371091125.post-26032340453067637532012-09-17T16:12:00.001+05:302012-09-17T16:12:45.751+05:30Explaining briefly about OOP<div dir="ltr" style="text-align: left;" trbidi="on">
An Impreseive Article on Object Oriented Programming on my major blog...<br />
<br />
<a href="http://saimaterial.wordpress.com/2012/09/17/explaining-briefly-about-oop/">http://saimaterial.wordpress.com/2012/09/17/explaining-briefly-about-oop/</a> </div>
Anonymoushttp://www.blogger.com/profile/04035027374716656450noreply@blogger.com0tag:blogger.com,1999:blog-8407673752371091125.post-5309040514124893552012-09-14T18:24:00.000+05:302012-09-14T18:24:16.951+05:30Google Maps Navigation Beta Version for Android arrives in India<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial;"><div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/normal Calibri, "Segoe UI", Arial; letter-spacing: normal; orphans: 2; outline-style: none; outline-width: 0px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
Finally, Google Maps Navigation Beta for Android has been rolled out in India delivering voice-based navigation in major parts of the country. Apart from this, the application even proffers live traffic updates.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/normal Calibri, "Segoe UI", Arial; letter-spacing: normal; orphans: 2; outline-style: none; outline-width: 0px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
In order to make use of this service, all that’s needed is to type in or dictate the name or the address of the place intended to visit and travelers are all set to go. Interestingly, users needn’t have worry about spelling mistakes as the app corrects it automatically to offer the required results. The application will provide directions orally in a familiar native accent on activating the Indian English locale setting.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/normal Calibri, "Segoe UI", Arial; letter-spacing: normal; orphans: 2; outline-style: none; outline-width: 0px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br style="outline-style: none; outline-width: 0px;" /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/normal Calibri, "Segoe UI", Arial; letter-spacing: normal; orphans: 2; outline-style: none; outline-width: 0px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
“We’re excited today to announce that both of these features are now available for Google Maps users in India — one of the most dynamic and fastest-growing markets for online map services worldwide. Google Maps Navigation (Beta) is free and accessible to any smartphone user running Android 2.2 or later, and live traffic information is visible on both the mobile and desktop versions of Google Maps,” reads a post on the official Google blog.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/normal Calibri, "Segoe UI", Arial; letter-spacing: normal; orphans: 2; outline-style: none; outline-width: 0px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br style="outline-style: none; outline-width: 0px;" /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/normal Calibri, "Segoe UI", Arial; letter-spacing: normal; orphans: 2; outline-style: none; outline-width: 0px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
The application is said to offer live traffic information for six major cities within the country including Bengaluru, New Delhi, Chennai, Pune, Hyderabad and Mumbai. On activating the traffic layer option, the app will provide colored highlights such as red for tight jams, while the yellow and green markings denote slow moving and free-flowing traffic, respectively. Users will also be able to find ‘typical’ traffic conditions for a specific time or day.</div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/normal Calibri, "Segoe UI", Arial; letter-spacing: normal; orphans: 2; outline-style: none; outline-width: 0px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br style="outline-style: none; outline-width: 0px;" /></div>
<div style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; font-size-adjust: none; font-stretch: normal; font: 15px/normal Calibri, "Segoe UI", Arial; letter-spacing: normal; orphans: 2; outline-style: none; outline-width: 0px; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
Google Maps Navigation Beta for Android can be picked up for free via the<span class="Apple-converted-space"> </span><a href="https://play.google.com/store?hl=en" style="outline-style: none; outline-width: 0px; text-decoration: none;"><span style="color: blue; outline-style: none; outline-width: 0px;">Play store</span></a>.</div>
</span></div>
Anonymoushttp://www.blogger.com/profile/04035027374716656450noreply@blogger.com0tag:blogger.com,1999:blog-8407673752371091125.post-17489731804676792822012-09-14T18:19:00.002+05:302012-09-14T18:19:32.676+05:30Date Problem when having Client & Server in different TimeZone<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "Arial","sans-serif";">Hi, I want to share my
problem and its solution i found..</span><br />
<span style="font-family: "Arial","sans-serif";"></span><o:p></o:p><br />
<strong><span style="font-family: "Arial","sans-serif";">Problem :</span></strong><span style="font-family: "Arial","sans-serif";"> I have developed one client
Application in which iam getting data from database in to DataView Object, Now
my task is to show the records on the Grid which are greater than or equal to
current system date.</span><o:p></o:p><br />
<span style="font-family: "Arial","sans-serif";">To do so i used following
code</span><o:p></o:p><br />
<span style="font-family: "Arial","sans-serif";">(overview not exactly)<o:p></o:p></span><br />
<o:p> </o:p><br />
<span style="color: blue; font-family: Consolas; font-size: 10pt; mso-bidi-font-family: Arial;">String </span><span style="font-family: Consolas; font-size: 10pt; mso-bidi-font-family: Arial;">today = <span style="color: #2b91af;">DateTime</span>.Now.ToString();</span><span style="font-family: "Arial","sans-serif";"><o:p></o:p></span><br />
<span style="font-family: Consolas; font-size: 10pt; mso-bidi-font-family: Arial;">dv.RowFilter = <span style="color: blue;">string</span>.Format(<span style="color: #a31515;">"TODATE >=#{0}#"</span>, today);</span><span style="font-family: "Arial","sans-serif";"><o:p></o:p></span><br />
<span style="font-family: "Arial","sans-serif";"><o:p><span style="font-family: Times New Roman;"> </span></o:p></span><br />
<span style="font-family: "Arial","sans-serif";">Its working fine on some
systems and raising exceptions on some other systems.</span><o:p></o:p><br />
<strong><span style="font-family: "Arial","sans-serif";">Solution :</span></strong><span style="font-family: "Arial","sans-serif";"> the exact problem is culture the
system. When the culture is different what we expecting then its getting
execption to fix this problem i coded the above code as follows:</span><o:p></o:p><br />
<span style="font-family: Consolas; font-size: 10pt; mso-bidi-font-family: Arial;"><o:p><span style="font-family: Times New Roman; font-size: small;"> </span></o:p></span><br />
<span style="font-family: Consolas; font-size: 10pt; mso-bidi-font-family: Arial;">CultureInfo culture = <span style="color: blue;">new</span> CultureInfo(<span style="color: #a31515;">"en-US"</span>);</span><span style="font-family: "Arial","sans-serif";"><o:p></o:p></span><br />
<span style="color: blue; font-family: Consolas; font-size: 10pt; mso-bidi-font-family: Arial;">String </span><span style="font-family: Consolas; font-size: 10pt; mso-bidi-font-family: Arial;">today = <span style="color: #2b91af;">DateTime</span>.Now.ToString(<span style="color: #a31515;">"d"</span>,culture);</span><span style="font-family: "Arial","sans-serif";"><o:p></o:p></span><br />
<span style="font-family: Consolas; font-size: 10pt; mso-bidi-font-family: Arial;">dv.RowFilter = <span style="color: blue;">string</span>.Format(<span style="color: #a31515;">"TODATE >=#{0}#"</span>, today);<o:p></o:p></span><br />
<span style="font-family: "Arial","sans-serif";"><o:p><span style="font-family: Times New Roman;"> </span></o:p></span><br />
<span style="font-family: "Arial","sans-serif";">Now this code perfectly works
on any ssytem with any culture.</span><o:p></o:p><br />
<span style="font-family: "Arial","sans-serif";">Happy to Share Code</span> <o:p></o:p><br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<o:p> </o:p></div>
</div>
Anonymoushttp://www.blogger.com/profile/04035027374716656450noreply@blogger.com0tag:blogger.com,1999:blog-8407673752371091125.post-62189787718235326702012-09-14T18:05:00.001+05:302012-09-14T18:05:15.964+05:30You are attempting to access powerpivot data that was added using a newer version of powerpivot<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt; mso-outline-level: 1;">
<span style="background: white; font-family: "Segoe UI","sans-serif"; font-size: 10pt;">The Report which you are
using is built on new power pivot version, for this reason reports are not
working on old power pivot version and showing below error message.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0cm 0cm 0pt; mso-outline-level: 1;">
<span style="background: white; font-family: "Segoe UI","sans-serif"; font-size: 10pt;"><o:p><span style="font-family: Times New Roman; font-size: small;"> </span></o:p></span></div>
<br />
<div style="background: white; line-height: 12pt;">
<strong><u><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;">Resolution:</span></u></strong><strong><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;"> </span></strong><span class="apple-converted-space"><b><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;"> </span></b></span><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;">Please install new
version of power pivot (i.e. 11.0.2100.60) from below link.<o:p></o:p></span></div>
<br />
<div style="background: white; line-height: 12pt;">
<strong><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;"> </span></strong><b><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;"><br />
</span></b><a href="http://www.microsoft.com/en-us/download/details.aspx?id=29074" target="_blank"><span style="color: windowtext; font-family: "Segoe UI","sans-serif"; font-size: 10pt;">http://www.microsoft.com/en-us/download/details.aspx?id=29074</span><span class="apple-converted-space"><span style="color: windowtext; font-family: "Segoe UI","sans-serif"; font-size: 10pt; text-decoration: none; text-underline: none;"> </span></span><span style="color: windowtext; font-family: "Segoe UI","sans-serif"; font-size: 10pt; mso-no-proof: yes; text-decoration: none; text-underline: none;"><v:shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f">
<v:stroke joinstyle="miter">
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0">
<v:f eqn="sum @0 1 0">
<v:f eqn="sum 0 0 @1">
<v:f eqn="prod @2 1 2">
<v:f eqn="prod @3 21600 pixelWidth">
<v:f eqn="prod @3 21600 pixelHeight">
<v:f eqn="sum @0 0 1">
<v:f eqn="prod @6 1 2">
<v:f eqn="prod @7 21600 pixelWidth">
<v:f eqn="sum @8 21600 0">
<v:f eqn="prod @7 21600 pixelHeight">
<v:f eqn="sum @10 21600 0">
</v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas>
<v:path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f">
<o:lock aspectratio="t" v:ext="edit">
</o:lock></v:path></v:stroke></v:shapetype><v:shape alt="Description: http://social.technet.microsoft.com/wiki/cfs-file.ashx/__key/communityserver-components-sitefiles/10_5F00_external.png" href="http://www.microsoft.com/en-us/download/details.aspx?id=29074" id="Picture_x0020_1" o:button="t" o:spid="_x0000_i1025" style="height: 7.5pt; mso-wrap-style: square; visibility: visible; width: 7.5pt;" target=""_blank"" type="#_x0000_t75">
<v:fill o:detectmouseclick="t">
<v:imagedata o:title="10_5F00_external" src="file:///C:\Users\Praveen\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png">
</v:imagedata></v:fill></v:shape></span></a><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;"><o:p></o:p></span></div>
<br />
<div style="background: white; line-height: 12pt;">
<strong><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;"> </span></strong><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;"><o:p></o:p></span></div>
<br />
<div style="background: white; line-height: 12pt;">
<strong><u><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;">Impact :</span></u></strong><span class="apple-converted-space"><b><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;"> </span></b></span><strong><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;"> </span></strong><span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;">If you are
installed new power pivot version from above link existing reports which are
built on old Power pivot will open with the below message in a dialogue
box<o:p></o:p></span></div>
<br />
<div style="background: white; line-height: 12pt;">
<span style="font-family: "Segoe UI","sans-serif"; font-size: 10pt;">Saying that “<i style="mso-bidi-font-style: normal;">Do you want Upgrade the workbook</i>”, if you click on OK the report
will work fine.<o:p></o:p></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/04035027374716656450noreply@blogger.com0tag:blogger.com,1999:blog-8407673752371091125.post-62129607988699502632012-09-13T17:37:00.000+05:302012-09-13T17:37:07.561+05:30Solution for Parsing an Excel file in C# and the cells seem to get cut off at 255 characters<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><b style="mso-bidi-font-weight: normal;">Problem: </b>An excel
sheet containing say 10 rows and in couple of columns in couple of rows having
data with more than 255 characters. When I try to upload this file in ASP.Net
application using traditional OLEDB provider I cannot saw the whole data in
particular cell means which is chopping out or we can say trimming to 255
characters when loaded in to my dataset object.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><b style="mso-bidi-font-weight: normal;">Solution: </b>Having
done sleepless nights I found some solutions to fix this issue… those are presented
below<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><u>Solution-1</u>:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">If your application is used only on one computer then you
can directly go to the following registry settings and change the <i style="mso-bidi-font-style: normal;">TypeGuessRows</i><span style="mso-spacerun: yes;"> </span>value.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<i style="mso-bidi-font-style: normal;"><span style="color: grey; mso-themecolor: background1; mso-themeshade: 128;"><span style="font-family: Calibri;">HKLM\Software\Microsoft\Jet\4.0\Engines\Excel\TypeGuessRows<o:p></o:p></span></span></i></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">64 bit
systems:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="color: grey; mso-themecolor: background1; mso-themeshade: 128;"><span style="font-family: Calibri;">HKLM\SOFTWARE\wow6432node\microsoft\jet\4.0\engines\excel\TypeGuessRows<o:p></o:p></span></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">By setting this value to zero, the all lines of your
spreadsheet are scanned for type guessing, rather than the default of 8. If any
text fields longer than 255 chars are encountered, then those columns are
deemed to be memo fields.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<i style="mso-bidi-font-style: normal;"><span style="font-family: Calibri;">Note that you are
still not 100% guaranteed to get the right data types, depending on your data.<o:p></o:p></span></i></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Note also the HKLM scope of this key though - it will affect
every OleDB Excel import by any process on that machine and this lead to
degrade performance depending on the size of the data.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><u>Solution-2</u>:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">A second way
to work around this problem (without modifying the registry) is to make sure
that rows with fields, which have data 255 characters or greater, are present
in the first 8 rows (default value of <i style="mso-bidi-font-style: normal;">TypeGuessRows</i>
is 8) of the source data file.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;"><u>Solution-3</u>: <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">This is the recommended solution by me as there is no need
to change any registry or take care to have those lengthy data to be in first 8
rows. Instead we have a tool called <b style="mso-bidi-font-weight: normal;">NPOI
</b>which can be download from npoi.codeplex.com.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Using this dll we can upload the spreadsheet without
worrying of chopping your data and also it has many features like creating the
spreadsheet on fly including charts, reports etc.., for more information you
can find on this site npoi.codeplex.com.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<span style="font-family: Calibri;">Anyway reading data using this NPOI is different from the
traditional OLEDB provider. Please find the following method which with return
a Data Table object by sending the File Path and the respective SheetName as
input.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">static</span> <span style="color: #2b91af;">DataTable</span> getExcelData(<span style="color: blue;">string</span>
FileName, <span style="color: blue;">string</span> strSheetName)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">DataTable</span> dt = <span style="color: blue;">new</span>
<span style="color: #2b91af;">DataTable</span>();<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">HSSFWorkbook</span> hssfworkbook;<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">using</span> (<span style="color: #2b91af;">FileStream</span>
file = <span style="color: blue;">new</span> <span style="color: #2b91af;">FileStream</span>(FileName,
<span style="color: #2b91af;">FileMode</span>.Open, <span style="color: #2b91af;">FileAccess</span>.Read))<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>hssfworkbook = <span style="color: blue;">new</span> <span style="color: #2b91af;">HSSFWorkbook</span>(file);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">ISheet</span> sheet =
hssfworkbook.GetSheet(strSheetName);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>System.Collections.<span style="color: #2b91af;">IEnumerator</span> rows =
sheet.GetRowEnumerator();<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">while</span> (rows.MoveNext())<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">IRow</span> row = (<span style="color: #2b91af;">HSSFRow</span>)rows.Current;<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">if</span> (dt.Columns.Count == 0)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">for</span> (<span style="color: blue;">int</span>
j = 0; j < row.LastCellNum; j++)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>{<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>dt.Columns.Add(row.GetCell(j).ToString());<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">continue</span>;<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">DataRow</span> dr = dt.NewRow();<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i
< row.LastCellNum; i++)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: #2b91af;">ICell</span> cell = row.GetCell(i);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">if</span> (cell == <span style="color: blue;">null</span>)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>{<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>dr[i] = <span style="color: blue;">null</span>;<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">else</span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>{<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>dr[i] = cell.ToString();<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>dt.Rows.Add(dr);<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">return</span> dt;<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 10pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">May be I
presented the solutions straight forward without more explanation or discussion
but presently my motto is to provide you the reasonable and permanent solution
for those who suffering with similar problem.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">Hope this
research and the code helps you a lot.. if so please drop a comment below which
may be more encroached for me..<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<span style="font-family: Calibri;">Happy Coding
</span><span style="font-family: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">J</span></span><span style="font-family: Calibri;"> <span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
</div>
Anonymoushttp://www.blogger.com/profile/04035027374716656450noreply@blogger.com0