Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to read client side excel (.xls) file

Posted on 2004-08-09
5
Medium Priority
?
3,972 Views
Last Modified: 2010-07-27
I am in need of reading client side excel file.
I understand i ned to upload it but i cannot write ti to a disk.

Therefore I need to rea it on the fly.

Can anyone tell me how to do it.
thanks
0
Comment
Question by:sinha_punit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
AerosSaga earned 500 total points
ID: 11752538
Have them export the Excel file to a CSV comma seperated value file then use this code.
This will give you an upload stream to read from or save, in your case read:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
       Inherits="WebApplication2.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>WebForm1</title>
            <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
            <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
      </HEAD>
      <body MS_POSITIONING="GridLayout">
            <%
            if page.ispostback=false then
            %>
            <form runat="server" enctype="multipart/form-data" ID="Form1">
                    <input type="file" id="file1" runat="server" NAME="file1"
                            style="Z-INDEX: 103; LEFT: 324px; POSITION: absolute; TOP: 117px">
                            
                  <asp:Button id="btn1" runat="server" text="Upload" onclick="upload"
                            style="Z-INDEX: 104; LEFT: 324px; POSITION: absolute; TOP: 172px" />
            </form>
            <%
            end if
            %>
      </body>
</HTML>

Imports System.IO

Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents btn1 As System.Web.UI.WebControls.Button
    Protected WithEvents file1 As System.Web.UI.HtmlControls.HtmlInputFile

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init      
        InitializeComponent()
    End Sub

#End Region
   
    Public Sub Upload(ByVal sender As Object, ByVal e As System.EventArgs)

        'You can do this to save the file to the server if you like
        'file1.PostedFile.SaveAs("MyFile.csv")

        Dim r As New StreamReader(file1.PostedFile.InputStream())
        Dim strBuffer As String = r.ReadToEnd
       
        'DO SOMETHING HERE WITH strBuffer
       
        r.Close()
    End Sub
End Class

After that you will have to parse throught the csv file with something like text.split see here for example usage:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemstringclasssplittopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctsplit.asp

Regards,

Aeros

0
 
LVL 1

Author Comment

by:sinha_punit
ID: 11752602
thanks aeros for the fast reply,

but the thing is i cannot ask the users to export to csv,
they will upload xls and i need to read from xls without saving to disk.

thanks
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11752738
well the above code will upload to a stream, and then to a string, I'm just not sure what kind of format the string will be in when you upload a.csv file.  If you start with that code you should at least be able to see what the string is going to look like and then we can go from there.

Regards,

Aeros
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question