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

Alpha5 and MS Excel with Multiple Worksheets

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

  • Alpha5 and MS Excel with Multiple Worksheets

    I wonder if the V8 can be able to export data to a single Excel file with multiple worksheets. I currently have V5, V6 and V7. Neither of them can do this.

    This is very important because our customers just want all the data in one file instead of multiple files. In order to do that now, I have to do extra work by combining the data from multiple files together.

    Anyone has the information, please help.

    thanks.

  • #2
    Re: Alpha5 and MS Excel with Multiple Worksheets

    No, V8 does not natively create multiple worksheets in an excel file. You can use Alpha's ole methods to do this (all the way back to v5).
    There can be only one.

    Comment


    • #3
      Re: Alpha5 and MS Excel with Multiple Worksheets

      Not natively. Look up info in Alpha docs and Excel docs on OLE (Object Linking and Embedding). You will have to program this for it to work.

      Comment


      • #4
        Re: Alpha5 and MS Excel with Multiple Worksheets

        Thanks, Doug and Stan.

        what language should I use to program the OLE?

        Comment


        • #5
          Re: Alpha5 and MS Excel with Multiple Worksheets

          Originally posted by ppham View Post
          Thanks, Doug and Stan.

          what language should I use to program the OLE?
          Xbasic.

          Example attached. One form, one button. Button executes function taking parameter from variable on form. Function writes records from two tables to separate sheets of excel workbook, deletes third sheet. Saves exported file as name in form variable. (Doesn't check for name legality so that's the user's problem.)

          The example is a bit slow because I included print setup commands. Removing those lines will speed the process up greatly.
          There can be only one.

          Comment


          • #6
            Re: Alpha5 and MS Excel with Multiple Worksheets

            You're so responsive, Stan. Thank you so much. I will try the sample.

            Comment


            • #7
              Re: Alpha5 and MS Excel with Multiple Worksheets

              Hi Stan,
              It looks like the OLE only allows to create 3 worksheets per Excel file. I tried to create the 4th one, and I got the following messages:


              ERROR: command: xlApp.Sheets(4).Activate()
              OLE Automation Error. COM error source is unknown. COM error description is unknown.
              scode = -2147352565 (0x8002000b). Formated System Message:
              An attempt was made to load a program with an incorrect format.


              Please advise!

              Thank you.

              Comment


              • #8
                Re: Alpha5 and MS Excel with Multiple Worksheets

                When you create a spreadsheet with the ole method the default is 3, set in Excel I think. If you need more just stick in some

                xlApp.Workbooks.Add()

                lines to create them, probably before anything after the create. That way when you start referencing them they should be in order.
                There can be only one.

                Comment


                • #9
                  Re: Alpha5 and MS Excel with Multiple Worksheets

                  Thanks, Stan.

                  But that line is already added at the begining of the function.
                  if alltrim(filename) = ""
                  ui_msg_box("Sorry","No filename given for saving.")
                  exprt = .F.
                  end
                  end if

                  Dim xlApp as p
                  Dim myCell as c
                  xlApp = ole.Create("Excel.Application")
                  xlApp.Workbooks.Add() 'adds a workbook object
                  xlApp.DisplayAlerts = .F.


                  Do you mean adding another line somewhere in the function?

                  Comment


                  • #10
                    Re: Alpha5 and MS Excel with Multiple Worksheets

                    Not that I actually know, but wouldn't it be:

                    Worksheets.Add()

                    Comment


                    • #11
                      Re: Alpha5 and MS Excel with Multiple Worksheets

                      Good catch, Doug. I was posting from memory which is always risky. I'll have to test and get back but I think it would be

                      xlapp.Worksheets.Add()

                      and you can

                      xlapp.Sheets(3).Select()'select sheet 3
                      xlapp.Sheets.Add()'adds a sheet before 3, can't add after 3 this way
                      xlapp.Sheets(4).Select()'select sheet 4
                      xlapp.Sheets(4).Move(3)'move it after 3

                      but I'll have to test that tomorrow.
                      There can be only one.

                      Comment


                      • #12
                        Re: Alpha5 and MS Excel with Multiple Worksheets

                        Testing this morning tells me the move statements above aren't right and it is just easier to refer to the sheets by index (absolute position) and rename them.

                        xlApp.Worksheets.Add()
                        and
                        xlApp.Sheets.Add()

                        seem to be equivalent.

                        Reference to sheets by index is

                        xlApp.Sheets(1.Select() 'leftmost sheet
                        xlApp.Sheets(2).Select() 'second to leftmost
                        etc
                        There can be only one.

                        Comment


                        • #13
                          Re: Alpha5 and MS Excel with Multiple Worksheets

                          Stan and Doug,
                          I think I found a way to add more than 3 worksheets in an excel file. I just modified your code a little bit, Stan. And I got 5 worksheet created in the excel file.

                          I attach the file here for your reference.

                          thanks a lot for your help.

                          Comment


                          • #14
                            Re: Alpha5 and MS Excel with Multiple Worksheets

                            Here is the file. The order of the worksheets is not important as long as I get the number of worksheets I want.

                            thanks again.

                            Comment

                            Working...
                            X