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

    Export to Excel Tabs?

    Hi,

    I have searched and know that it has been mentioned before but cant find answer.

    Two part question:

    How do you export to a named starting cell on an excel spreadsheet?

    eg A6.

    Also, how do you export to a named cell and Named Tab in an Excel spreadsheet?
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

    #2
    Re: Export to Excel Tabs?

    Other than OLE or using OLE?
    There can be only one.

    Comment


      #3
      Re: Export to Excel Tabs?

      Hi Stan,

      By what ever is best.
      Regards
      Keith Hubert
      Alpha Guild Member
      London.
      KHDB Management Systems
      Skype = keith.hubert


      For your day-to-day Needs, you Need an Alpha Database!

      Comment


        #4
        Re: Export to Excel Tabs?

        Create a spreadsheet in your c:\ root directory named keith's sheet.xls.
        Create this function in AlphaSports.

        Code:
        FUNCTION ex_keith AS L (excelname AS C, newname AS C )
        	ex_keith = .F.
        	Dim xlApp as p
        	dim myCell as c
        	xlApp = ole.create("Excel.Application")
        	xlApp.Workbooks.Open(excelname)
        	'xlApp.Visible = .T. 'comment this line out if you don't want to see Excel
        	tbl = table.open("customer")
        	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 = 6
        	FOR t = 0 TO recs
        		xlApp.Range("A"+alltrim(str(start_cell+t))).Select()
        		xlApp.ActiveCell.Formula = alltrim(tbl.firstname)
        		xlApp.Range("B"+alltrim(str(start_cell+t))).Select()
        		xlApp.ActiveCell.Formula = alltrim(tbl.lastname)
        		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:C").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
        Go to the interactive editor and run

        ? ex_keith("C:\keith's sheet.xls","C:\keith's new sheet.xls")

        You should get a .T. result.

        Take a look at the new spreadsheet created in the C:\ root directory

        "C:\keith's new sheet.xls"

        When you get that far we can talk about the changes necessary to address a specific tab.
        There can be only one.

        Comment


          #5
          Re: Export to Excel Tabs?

          This is fun.

          Got new sheet in root.

          Function works great.
          Regards
          Keith Hubert
          Alpha Guild Member
          London.
          KHDB Management Systems
          Skype = keith.hubert


          For your day-to-day Needs, you Need an Alpha Database!

          Comment


            #6
            Re: Export to Excel Tabs?

            OK, now we're cooking!

            If you want to address a specific sheet you use

            XlApp.Sheets("sheetname").Select() 'note quotes

            or

            XlApp.Sheets(sheetnumber).Select() 'note lack of quotes left to right position

            One of these would follow immediately after

            xlApp.Workbooks.Open(excelname)
            There can be only one.

            Comment


              #7
              Re: Export to Excel Tabs?

              Hi,
              I'm hoping I can tag along...since this has to do with Excel.
              I have a table with data ready for export into an existing Excel worksheet. The Excel worksheet is AZ state mandated worksheet for the first 6 rows and I need to be able to take the data from the table and add it to the worksheet starting at row 7. I have attached the table and the worksheet if you might be able to help. I have searched the help file and tried different SQL commands and DAO commands and I can get close, but I can't get data into the spreadsheet.

              Can you offer any ideas?

              I would appreciate any help or a direction to look to for help.

              Thanks,
              mike
              Mike Reed
              Phoenix, AZ

              Comment


                #8
                Re: Export to Excel Tabs?

                Your version would be...

                Code:
                FUNCTION ex_mike AS L (excelname AS C, newname AS C )
                	ex_mike = .F.
                	Dim xlApp as p
                	dim myCell as c
                	xlApp = ole.create("Excel.Application")
                	xlApp.Workbooks.Open(excelname)
                	'xlApp.Visible = .T. 'comment this line out if you don't want to see Excel
                	tbl = table.open("non_prov")
                	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 = 7
                	FOR t = 0 TO recs - 1
                		xlApp.Range("A"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.contr_id)
                		xlApp.Range("B"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.regno)
                		xlApp.Range("C"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.called_in)
                		xlApp.Range("D"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.time_called)
                		xlApp.Range("E"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.Nps)
                		xlApp.Range("F"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.sked_beg_time)
                		xlApp.Range("G"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.County)
                		xlApp.Range("H"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.Ps_name)
                		xlApp.Range("I"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.Ps_zip)
                		xlApp.Range("J"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.ahcccsid)
                		xlApp.Range("K"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.Svc)
                		xlApp.Range("L"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.agy_pref_code)
                		xlApp.Range("M"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.mem_pref_code)
                		xlApp.Range("N"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.reason_code)
                		xlApp.Range("O"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.blank)
                		xlApp.Range("P"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.Outcome_code)
                		xlApp.Range("Q"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = tbl.hrs_auth
                		xlApp.Range("R"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = tbl.Hrs_resolve
                		xlApp.Range("S"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.time_len)
                		xlApp.Range("T"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.mem_svc)
                		xlApp.Range("U"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.Mem_timecode)
                		xlApp.Range("V"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.auth_not_code)
                		xlApp.Range("W"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.care_paid_code)
                		xlApp.Range("X"+alltrim(str(start_cell+t))).Select()
                		xlApp.ActiveCell.Formula = alltrim(tbl.comments)
                		tbl.fetch_next()
                	NEXT t
                	'xlApp.Columns("A:X").Autofit()' NOT USED
                	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_mike = .T.
                END FUNCTION
                Usage like

                Code:
                EX_mike("C:\tempdb\Non_provision_master\Non_provision_master.xls","C:\tempdb\Non_provision_master\New Non_provision_master.xls")
                There can be only one.

                Comment


                  #9
                  Re: Export to Excel Tabs?

                  Originally posted by Stan Mathews View Post
                  Create a spreadsheet in your c:\ root directory named keith's sheet.xls.
                  Create this function in AlphaSports.
                  Keith,

                  This line

                  FOR t = 0 TO recs

                  needs to be

                  FOR t = 0 TO recs - 1

                  in your function as well.
                  There can be only one.

                  Comment


                    #10
                    Re: Export to Excel Tabs?

                    Stan,

                    What can I say but a great big thank you.

                    That is why they call you Stan the Man.
                    Regards
                    Keith Hubert
                    Alpha Guild Member
                    London.
                    KHDB Management Systems
                    Skype = keith.hubert


                    For your day-to-day Needs, you Need an Alpha Database!

                    Comment


                      #11
                      Re: Export to Excel Tabs?

                      Imagine what you can do with that process. I haven't designed a report in years. Nobody wants one. They'd rather have spreadsheets that they can tweak further, dress up, play what if with, etc.

                      Glad you like it.

                      Generally I do any necessary sorting in the section

                      Code:
                      query.filter = ".T."
                      	query.order = "recno()"
                      	query.options = "I"
                      	query.description = "Temporary Query"
                      if you need to export calculated values not in the actual table you can do things like

                      xlApp.Sheets(1).Range("A6").Select
                      xlApp.ActiveCell.Formula = "=sum(A2:A4")"
                      xlApp.Selection.NumberFormat = "0.00"
                      Last edited by Stan Mathews; 03-25-2010, 03:22 PM.
                      There can be only one.

                      Comment


                        #12
                        Re: Export to Excel Tabs?

                        One typo in ex_mike

                        recs = ix.records_get())

                        should be

                        recs = ix.records_get()
                        There can be only one.

                        Comment


                          #13
                          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.

                          Comment


                            #14
                            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.
                            There can be only one.

                            Comment


                              #15
                              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
                              Mike Reed
                              Phoenix, AZ

                              Comment

                              Working...
                              X