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

Export to Excel Tabs?

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

  • Stan Mathews
    replied
    Re: Export to Excel Tabs?

    Remember post 9 in this thread? Since we are using

    for 0 to .... instead of starting at 1, we have to decrement the record count by 1. Your script should read

    FOR t = 0 TO recs - 1


    Not sure about the protected worksheet problem. Is it actually protected? Does it need to be? Will the password allways be the same?

    Leave a comment:


  • Keith Hubert
    replied
    Re: Export to Excel Tabs?

    Hi Stan,

    Here is the modified code that I'm using.

    I have 2 problems.

    1, The last record gets duplicated in the spreadsheet
    2, I get an error message because of the .Autofit()

    I have uploaded screen shots to show data before and after with error message.

    Your help is appreciated.
    'Date Created: 28-Apr-2010 11:58:13 AM
    'Last Updated: 28-Apr-2010 12:43:58 PM
    'Created By : Keith
    'Updated By : Keith
    FUNCTION export_sales2 AS L (excelname AS C, newname AS C )
    export_sales2 = .F.
    Dim xlApp as p
    dim myCell as c
    xlApp = ole.create("Excel.Application")
    xlApp.Workbooks.Open("keith_sheet")
    XlApp.Sheets("Tab 1").Select()
    xlApp.Visible = .T. 'comment this line out if you don't want to see Excel
    tbl = table.open("new_sales")
    query.filter = ".T."
    query.order = "recno()"
    query.options = "I"
    query.description = "Temporary Query"
    ix = tbl.query_create()
    recs = ix.records_get()
    tbl.fetch_first()
    start_cell = 9
    FOR t = 0 TO recs
    xlApp.Range("A"+alltrim(str(start_cell+t))).Select()
    xlApp.ActiveCell.Formula = alltrim(tbl.sales_rep)
    xlApp.Range("B"+alltrim(str(start_cell+t))).Select()
    xlApp.ActiveCell.Formula = tbl.Total_Invoice_Items__Extension
    'xlApp.Range("C"+alltrim(str(start_cell+t))).Select()
    'xlApp.ActiveCell.Formula = alltrim(tbl.email)
    tbl.fetch_next()
    NEXT t
    tbl.close()
    xlApp.Columns("A:B").Autofit()
    xlApp.Range("A1").Select()
    xlapp.DisplayAlerts = .F.
    xlApp.ActiveWorkbook.SaveAs(newname,-4143) '-4143 is latest supported version
    xlApp.Workbooks.Close()
    xlapp.DisplayAlerts = .T.
    xlApp.Quit()
    ex_keith = .T.
    END FUNCTION

    Leave a comment:


  • Stan Mathews
    replied
    Re: Export to Excel Tabs?

    The line

    xlApp.ActiveWorkbook.SaveAs(newname,-4143)

    is supposed to save in whatever the latest excel format. I don't have excel 2007 so I can't test it. If you have that version and it isn't working....

    Open excel and type something in a cell.
    Start recording a macro that does something, doesn't matter what, and then save the spreadsheet while the macro is still recording.
    Stop recording the macro.
    Edit the macro.

    You should see something like

    Code:
    ActiveWorkbook.SaveAs Filename:= _
            "C:\Documents and Settings\Keith\My Documents\Book1.xls", FileFormat:= _
            xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
            , CreateBackup:=False
    Find the Immediate window area at the bottom of the screen and type in

    ? xlNormal

    You should see something like

    Code:
    ? xlNormal
    -4143
    The number you see is what you need to plug into the script in the saveas line.

    If you don't have excel 2007 you can't save as "XLSX".
    Last edited by Stan Mathews; 04-24-2010, 11:33 AM.

    Leave a comment:


  • Keith Hubert
    replied
    Re: Export to Excel Tabs?

    Hi Stan,

    Sorry to come back to this, I do have a small problem. (we can leave that on one side for the moment)

    What do I need to change in the function to write to the new Excel extension of "XLSX"

    Leave a comment:


  • Stan Mathews
    replied
    Re: Export to Excel Tabs?

    If you are responding to my post, save your keystrokes.

    Leave a comment:


  • G Gabriel
    replied
    Re: Export to Excel Tabs?

    Actually, no example is needed. It's easy as pie.
    There is an interesting little known feature of Excel I discovered by just simply playing around and trying things that you would normally think would not work, but they do.

    In Excel, if you are in say sheet_1 you could make the value of a certain cell equals a cell in an entirely different sheet. That's basic stuff. Everybody knows that. But did you know you can make the value of any cell equal the value of any cell in an entirely different spreadsheet? and did you know that if you update the value of that external spreadsheet, it will update it in the current one?

    Knowing that, now you could export your alpha to any spreadsheet (or if you are so inclined, to a tab in the same Excel book) and simply make the values of the cells in the sheet that has all the fancy formatting equal the cells in that other sheet. In other words, that external sheet will be lurking in the background while your fancy spread sheet shows all the formatting you want all the values where you want them, with no scripts or any work whatsoever.

    No, you don't need to copy one cell at a time. All you need to do is adjust the anchors in the coordinates and do a mass copy and you are done in few seconds.

    Leave a comment:


  • Stan Mathews
    replied
    Re: Export to Excel Tabs?

    Keith,

    Familiar refrain? (posted on 12-09-2009, 02:25 PM )

    Hi Gabe,

    You wrote on th 12th November
    Quote:
    Keith:
    Sorry about the delay in getting back with you.
    That code involves a trick within a trick within a trick..

    We are still waiting to see this trick of yours.

    The only trick I see you do, and I must say you do it very well, is the vanishing one.

    You must remember, your answers are not just for my benefit but all users of this forum. It is not nice to make promises of showing how to do something and then not keeping to it.

    So, how about that trick within the trick?
    Thus far, no further reaponse.

    Leave a comment:


  • Stan Mathews
    replied
    Re: Export to Excel Tabs?

    Keith,

    Familiar refrain?

    Hi Gabe,

    You wrote on th 12th November
    Quote:
    Keith:
    Sorry about the delay in getting back with you.
    That code involves a trick within a trick within a trick..

    We are still waiting to see this trick of yours.

    The only trick I see you do, and I must say you do it very well, is the vanishing one.

    You must remember, your answers are not just for my benefit but all users of this forum. It is not nice to make promises of showing how to do something and then not keeping to it.

    So, how about that trick within the trick?

    Leave a comment:


  • Stan Mathews
    replied
    Re: Export to Excel Tabs?

    Promises, promises.

    Leave a comment:


  • Keith Hubert
    replied
    Re: Export to Excel Tabs?

    Hi Gabe,

    Yes I am curious.

    It will be most interesting to see a working example of your idea?

    Please post your sample as promised for us all to see.

    Leave a comment:


  • G Gabriel
    replied
    Re: Export to Excel Tabs?

    This is all fun and good.. but it might come as a big surprise to you that you do not need any scripts, no Activex, no OLE, ...nothing at all to do what you want.

    None of the above.

    If curious, I will post an example showing how to export to Excel while maintaining Excel's titles, formatting, and everything else, exporting to one sheet, dozen of sheets .. whatever you want.

    Leave a comment:


  • Stan Mathews
    replied
    Re: Export to Excel Tabs?

    Glad it works for you. As I mentioned in my reply to Cal, un-comment out the xlApp.Visible = .T. line and run the function if you want a giggle.

    Leave a comment:


  • Mike Reed
    replied
    Re: Export to Excel Tabs?

    Stan,

    Thank you so much! Works like a charm. I'm sure you have spent a lot of time learning/mastering this.

    Thanks for sharing your talent and expertise!

    mike

    Leave a comment:


  • Stan Mathews
    replied
    Re: Export to Excel Tabs?

    Bill,

    Valid point. My client base (company internal) is obviously different from most developers. As for the multiple grouping levels, I assume you use them to obtain group counts, totals, etc. Most of that can be done using Excel's Data menu, Subtotals which can be coded in the OLE.

    The spreadsheet generation with OLE was time consuming when I first started learning it. Once the basics were mastered (ha!) the finer points seemed easier. Much of the coding is reusable as you can see in comparing ex_keith() and ex_mike().

    Sort of like learning Alpha initially.

    One benefit is the wow factor when you remove the comment mark from the line

    xlApp.Visible = .T. 'comment this line out if you don't want to see Excel

    run the function and show someone that Alpha just created a spreadsheet for them and how. Excel opens, stuff gets put in lots of cells, the spreadsheet is saved, Excel closes. Might be a selling point for someone trying to develop for a current spreadsheet user.

    Leave a comment:


  • Bill Parker
    replied
    Re: Export to Excel Tabs?

    Stan,

    The idea of doing more output directly to Excel is appealing, but I certainly take advantage of multiple grouping levels, etc. that A5 makes pretty easy to use. Some of these reports can get fairly complex, and would seem daunting to render in Excel.

    How much more time do Excel reports require for YOU (not me) vs. A5's report writer. (It would take me way longer than you.)

    Bill.

    Leave a comment:

Working...
X