Results 1 to 3 of 3
  1. #1
    idhayanila is offline Member
    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Default Need a java code to read 2-dimensional excel file and write as 1-dimensional file

    I have tried vba macro it was working fine and as i am new to java i am unable to write code to convert 2-dimensional excel file and write as 1-dimensional file
    here by i attached the sample excel - i need the java code to convert it and also i attached the vba code which i used - please help me to sort it out

    Sub format_data()
    Dim ws As Worksheet
    Dim i As Long, j As Long, lrow As Long, lcol As Long, lastrow As Long

    Application.ScreenUpdating = False

    Set ws = Worksheets("Sheet2")
    ws.Range("A1:I1").Value = Split("Name,Name Code,Family Code,Family name,Location Code,Apartment Location, Apartment Logo, Facility, Cost", ",")
    ws.Rows(1).Font.Bold = True

    With Worksheets("Sheet1")
    lrow = .Range("A" & .Rows.Count).End(xlUp).Row
    lcol = .Range("IV1").End(xlToLeft).Column

    For j = 5 To lcol
    For i = 7 To lrow
    If .Cells(i, j).Value = "X" Then
    lastrow = ws.Range("A" & Rows.Count).End(xlUp).Row
    .Range(.Cells(1, j), .Cells(5, j)).Copy
    ws.Range("A" & lastrow + 1).PasteSpecial (xlPasteValues), Transpose:=True
    .Range("A" & i & "j" & i).Copy ws.Range("F" & lastrow + 1)
    End If
    Next i
    Next j

    End With

    ws.Cells.EntireColumn.AutoFit

    MsgBox "Done"

    Application.ScreenUpdating = True

    End Sub


    thank you in advance
    Attached Files Attached Files

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    946
    Rep Power
    2

    Default Re: Need a java code to read 2-dimensional excel file and write as 1-dimensional file

    Go and read up on Apache POI. It's a very easy library to read (an write) Excel sheets. Easy API, excellent documentation and lots of examples.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: Need a java code to read 2-dimensional excel file and write as 1-dimensional file

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. How to read Excel file with java
    By chetan-24 in forum New To Java
    Replies: 6
    Last Post: 09-13-2014, 12:43 PM
  2. 2 Dimensional Array write error to file
    By NewbieJavaProgramer in forum New To Java
    Replies: 2
    Last Post: 09-15-2012, 06:12 AM
  3. Replies: 7
    Last Post: 09-26-2011, 11:29 PM
  4. How to read Excel file in java
    By nagaraj in forum New To Java
    Replies: 7
    Last Post: 03-18-2011, 05:09 AM
  5. Replies: 5
    Last Post: 03-12-2011, 01:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •