Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Manipulating Excel Data from Columns to Records

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • gagsoft
    replied
    Re: Manipulating Excel Data from Columns to Records

    Hi Stan, Tom
    Thanks for the pointers.
    Just completed the macro in Excel 2013. I do not want to you strong language here, but it really sucks. Extremely slow and does not complete the macro as recorded although I used relative reference. So A5 is my only other option.

    Thanks for the advice
    Peter G

    Leave a comment:


  • Tom Henkel
    replied
    Re: Manipulating Excel Data from Columns to Records

    Peter,

    We need to import excel data from a couple of sources, ad we found that the import operation didn't do what we needed. we use a function "get_excel_data" that is parameter driven to create an array with as many columns and rows as needed.

    Once the data is in the array, we then populate the appropriate table with that data. It seems to work extremely well for us.

    this is the code that calls the function and populates our table.
    Code:
    '	ptr2 is an array that will contain the data brought in from the Unit AO CRL Listing for the next Month.
    '	it needs to be big enopugh to contain at least as many lines as are in the <month> WFNJ <year> sheet
    '	If there are more than 400 appointments, then it needs to be larger.
    	dim ptr2[400,6] as C
    	ptr2.clear()
    	get_excel_data("P:\UAPData\Unit AO Log\CB CRL Case Listing.xls",1,1,ptr2,2)
    	lastone = ptr2.first_empty()-1
    	ptr2.resize(lastone)
    	DIM i as N = 1
    	for i = 2 to lastone/6
    		tbl.enter_begin(.t.) 
    			tbl.pgms= ptr2[i,1]
    			tbl.caseno=ptr2[i,2]
    			tbl.lname = ptr2[i,3]
    			tbl.fname = ptr2[i,4]
    			tbl.appt_date = ctod(ptr2[i,5])
    			tbl.appt_time = if(len(trim(ptr2[i,6]))<7,"0"+left(ptr2[i,6],4)+" "+right(ptr2[i,6],2),left(ptr2[i,6],5)+" "+right(ptr2[i,6],2))
    		tbl.enter_end(.t.)
    	next i
    	tbl.close()
    Here is the function.
    Code:
    'Date Created: 17-Jul-2013 02:57:48 PM
    'Last Updated: 18-Jul-2013 01:36:14 PM
    'Created By  : Thomas Henkel
    'Updated By  : Thomas Henkel
    ' Variables passed:
    ' Filename = Name of excel workbook
    ' First row is numeric = first row to select  - usually 1 unless you have header rows
    ' First col is numeric, usually 1
    ' Data_Array is the pointer to the array from the calling script
    ' Sheet is numeric value of which sheet in the workbook to select
    Function get_excel_data as V (Filename as C, First_Row as N, First_Col as N, Data_Array as P, Sheet as N)
        dim MyObject as P
        dim row as N
        dim col as N
        dim rows as N
        dim cols as N
        dim cell as C
        dim temp as C
        cols = Data_Array.size(2)
        rows = Data_Array.size(1)
        on error goto quitting
        MyObject = ole.getobject(Filename)
        MyObject.Worksheets(Sheet).Select()
        for row = First_Row to  rows
            for col = First_Col to cols
                cell = get_col(col) + row
                Data_Array[row,col] = MyObject.activesheet.Cells.Range(cell)
            next col
        next row
    quitting:
        MyObject.close()
        delete MyObject
    end function
    Once the data is in the array, you can parse it however you need and then populate your table.

    ~~Disclaimer~~ I did take the function from the Alpha Help File "Reading Excel Spreadsheet with OLE".

    Hope it helps

    Tom
    Last edited by Tom Henkel; 10-03-2013, 08:28 AM. Reason: discalimer

    Leave a comment:


  • Stan Mathews
    replied
    Re: Manipulating Excel Data from Columns to Records

    I would do it in Excel. Doesn't sound too hard. Can you create a sample file, putting in false names, zip it up, and attach it here?

    Leave a comment:


  • gagsoft
    replied
    Re: Manipulating Excel Data from Columns to Records

    Hi Stan

    My excel file looks like this
    It has a header with Employee name and Number
    Then a view rows and columns of the employe finger clocking data
    Then a blank row and then the next employee's data in the same format.
    I want to create a columns on the left for employee name and number and insert the employee's detail for the number of rows applicable and then delete the rows in the header that containt the Employee details. This routine needs to be repeated for the number of employee headers.
    My question is : can I do this in Alpha or should I create an Excel macro. Basically I want to have a flat table that needs to be imported in MySQL.
    Many Thanks
    Peter G

    Leave a comment:


  • Stan Mathews
    replied
    Re: Manipulating Excel Data from Columns to Records

    Re-reading your post

    in Excel in columns such as
    Is that one word per column or one group of four words in each cell/row?

    Leave a comment:


  • Stan Mathews
    replied
    Re: Manipulating Excel Data from Columns to Records

    This should get you started.

    Code:
    Dim xlApp as p
    Dim myCell as c
    'open an ole link to excel
    xlApp = ole.GetObject("","Excel.Application")
    xlApp.Workbooks.Open("P:\test\book1.xls")
    xlApp.ActiveSheet.Name = "Concord" 'assign a name to the active sheet of the workbook
    xlApp.DisplayAlerts = .F.
    xlApp.ActiveWorkbook.Saveas("C:\temp"+chr(92)+"concord.xls")
    lastrow = xlApp.Activecell.SpecialCells("11").Row
    lastcol = xlApp.Activecell.SpecialCells("11").Column
    xlApp.Visible = .T. 'comment this line out if you don't want to see Excel
    nx_grp = 0
    for qs = 1 to lastrow
    	wds = ""
    	for qx = 1 to lastcol
    		xlApp.Sheets(1).Select()
    		xlApp.Range(chr(qx+64)+alltrim(str(qs))).Select()
    		wds = wds+xlApp.Selection.Value+crlf()
    	next qx
    	wds = remove_blank_lines(wds)
    	wds_cnt = w_count(wds,crlf())
    	proc = 1 + nx_grp
    	for each foo in wds
    		xlApp.Sheets("Sheet2").Select()
    		xlApp.Range("A"+alltrim(str(proc))).Select()
    		xlApp.Selection.Formula = foo.value
    		proc = proc+1
    	next qq
    	nx_grp = proc - 1
    next qs
    xlApp.ActiveWorkbook.Saveas("C:\temp"+chr(92)+"concord.xls") 'save all the changes
    xlApp.Workbooks.Close() 'close the workbook
    xlApp.DisplayAlerts = .T.
    xlApp.Quit() 'disconnect from Excel
    delete xlApp 'delete the pointer variable
    Last edited by Stan Mathews; 05-03-2013, 01:20 PM. Reason: fixed script

    Leave a comment:


  • nugget3825
    started a topic Manipulating Excel Data from Columns to Records

    Manipulating Excel Data from Columns to Records

    I have a text file which I've saved in "Text Format" only. The purpose is to build a "concordance" file in Word in building a rather lengthy index.

    Currently, I have the document in Excel in columns such as:

    The quick brown fox

    jumped over the fence


    I would like to be able to import into Alpha and have the resulting file end up looking like:

    The
    quick
    brown
    fox
    jumped
    over
    the fence

    Any creative solutions are invited.

    Thanks,

    lar
Working...
X