Re: Save a Report to Excel
Thanks! It's all working perfectly now!
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 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:
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:
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.
- 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
Save a Report to Excel
Collapse
X
-
Re: Save a Report to Excel
Hi Candy,
In the beginning of the script, it seems you are trying to set the proc_num variable before you have fetched the first record in the table:
Code:out_fil = file.create("S:\Web Order Download\NewOrders.csv",FILE_RW_EXCLUSIVE) tbl = table.open("tpi-ready.dbf") tbl.order("Num") [COLOR=#FF0000]proc_num = tbl.num[/COLOR] tbl.fetch_first() while .not. tbl.fetch_eof() while .not. tbl.fetch_eof() .and. tbl.num = proc_num ...
Also in this section:
Code:tbl.fetch_next() if tbl.num <> proc_num if ths_tax_amt<>0 out_fil.write_line(ths_num+","+ths_type+","+ths_date+","+ths_class+","+ths_shipdate+","+ths_billphone+","+ths_billemail+","+ths_billfirst+","+ths_billlast+","+ths_billaddr1+","+ths_billaddr2+","+ths_billcity+","+ths_billstate+","+ths_billzip+","+ths_shipfirst+","+ths_shiplast+","+ths_shipaddr1+","+ths_shipaddr2+","+ths_shipcity+","+ths_shipstate+","+ths_shipzip+","+ths_shipphone+","+ths_Tax_Sku+","+ths_Tax_Descr+","+"1,"+ths_tax_amt+","+ths_cc+","+ths_salesrep) end if
ths_shippingline = tbl.shippingitemnew
ths_taxcode = tbl.sales_tax_code
ths_tax_amt = tbl.tax_amt
ths_DiscSku = tbl.discount_sku
ths_DiscDesc = tbl.discount_descrip
ths_ShipSku = tbl.shipping_sku
ths_ShipDesc = tbl.shipping_descr
ths_Tax_Sku = tbl.tax_sku
ths_Tax_descr = tbl.tax_descrLast edited by MoGrace; November 14, 2015, 08:12 PM.
Leave a comment:
-
Re: Save a Report to Excel
This worked for a few years! Now I am having another issue which I'm hoping someone can help with!
The last line of each record is the shipping. I need to have a sales tax line that is written to the "NewOrders.csv" just like the shipping line is written. When I run the code as attached, I get the results as in the sample file attached. Everything works fine except the very last records. The shipping line does not get written to NewOrders.csv at all.
Any suggestions?
Leave a comment:
-
Re: Save a Report to Excel
I just had to add all of my multitude of other fields.
Leave a comment:
-
Re: Save a Report to Excel
[QUOTE=Stan Mathews;616769]Try this on your table. Rename the table (in red) to your actual table name. Examine the output file created in the c:\temp directory. (Create that directory first if you don't have one.)
Wow! Thanks so much, it seems to work, I just had to add all of my multitude of other fields. So far so good!
Leave a comment:
-
Re: Save a Report to Excel
Great! Thanks, I'll see what I can do with this and report back!
Leave a comment:
-
Re: Save a Report to Excel
Try this on your table. Rename the table (in red) to your actual table name. Examine the output file created in the c:\temp directory. (Create that directory first if you don't have one.)
Code:out_fil = file.create("C:\temp\candy_orders.csv",FILE_RW_EXCLUSIVE) tbl = table.open("[COLOR="#FF0000"][SIZE=5]candy[/SIZE][/COLOR]") tbl.order("Num") proc_num = tbl.num tbl.fetch_first() while .not. tbl.fetch_eof() while .not. tbl.fetch_eof() .and. tbl.num = proc_num ths_num = tbl.NUM ths_name = alltrim(tbl.ship_name_first)+" "+ alltrim(tbl.ship_name_last) ths_addr = alltrim(tbl.ship_name_address_1) ths_item = alltrim(tbl.item_sku) ths_itmprc = alltrim(str(tbl.item_price,10,2)) ths_disccd = alltrim(tbl.discount_code) ths_shpamt = alltrim(str(tbl.ship_amt,10,2)) out_fil.write_line(ths_num+","+ths_name+","+ths_addr+","+ths_item+","+ths_itmprc) out_fil.write_line(ths_num+","+ths_name+","+ths_addr+","+ths_disccd) tbl.fetch_next() if tbl.num <> proc_num out_fil.write_line(ths_num+","+ths_name+","+ths_addr+","+ths_shpamt) end if end while proc_num = tbl.NUM end while out_fil.write_line(ths_num+","+ths_name+","+ths_addr+","+ths_shpamt) out_fil.flush() out_fil.close() tbl.close()
Leave a comment:
-
Re: Save a Report to Excel
Originally posted by Stan Mathews View PostThanks, Al. I have the file.
Candy,
I'll need a bit more information about your desired csv output format.
[Row 1:] Num, Name, Address, Item, Item Price... [more but not needed for this example]
[Row 2:] Num, Name, Address, Discount Code, [more]
[Row 3:] Num, Name Address, Item[2] Item Price...
[Row 4:] Num, Name Address, Discount Code...
[Last Row for each "Num"]: Num, Name, Address, Shipping Amount
Looking at your table (as imported) the first num is SFH21985 which has one item. You want the csv file to have three lines, one for the item, one for the discount code, one for the shipping amount. I need to know what you want on lines 1 and 2 where you have [more]. I'm assuming the [Row 1:] portion of each line is not to be included, it is only there for clarity.
Row 1: Item 1 with all other columns (num, name, etc)
Row 2: The item column will now have the discount code instead of an item description and then the row will have all other columns (num, name, etc) the same
Row 3: Item 2 with all columns
Row 4: Discount code in the item column
Row 5: Item column will now be shipping information instead of item description plus all the other columns the same
The last line always has to be the shipping amount. Hope it makes sense. I have to have it in this format because that's the way QB calculates correctly.
Leave a comment:
-
Re: Save a Report to Excel
Thanks, Al. I have the file.
Candy,
I'll need a bit more information about your desired csv output format.
[Row 1:] Num, Name, Address, Item, Item Price... [more but not needed for this example]
[Row 2:] Num, Name, Address, Discount Code, [more]
[Row 3:] Num, Name Address, Item[2] Item Price...
[Row 4:] Num, Name Address, Discount Code...
[Last Row for each "Num"]: Num, Name, Address, Shipping Amount
Looking at your table (as imported) the first num is SFH21985 which has one item. You want the csv file to have three lines, one for the item, one for the discount code, one for the shipping amount. I need to know what you want on lines 1 and 2 where you have [more]. I'm assuming the [Row 1:] portion of each line is not to be included, it is only there for clarity.
Leave a comment:
-
Re: Save a Report to Excel
Originally posted by candyperry View PostHere's the table in txt format. Thanks for any help!
Candy
____
From: Al Buchholz
Too much personal information in the file.
I removed the attachment and will send directly to Stan...
[ATTACH=CONFIG]32719[/ATTACH]
Leave a comment:
-
Re: Save a Report to Excel
Here's the table in txt format. Thanks for any help!
Candy
____
From: Al Buchholz
Too much personal information in the file.
I removed the attachment and will send directly to Stan...
blank.PNG
Leave a comment:
-
Re: Save a Report to Excel
A sample table would be helpful if you want assistance writing that xbasic.
Leave a comment:
-
Re: Save a Report to Excel
You should write some xbasic code to build the csv the way you need it.
Leave a comment:
-
Re: Save a Report to Excel
I'm not sure the driver is what I need. What I'm trying to do is import sales data from our website directly into QB so we don't have to manually enter every order. We're able to export certain data from our website, then I'm using Alpha 5 to manipulate the data into a format that will place all of the information into each person's sales receipt in QB. We have another program, Transaction Pro Importer that takes a csv file and puts all the information into its proper spot in QB. I have manually made a csv file to test and find that I need the formatting as above. Doing the report in Alpha gives me the data in the order I need it and at one point it exported into excel in the proper way, but once I add too many fields to the report, I can't get it into Excel.
Any other ideas?
Thanks!
Leave a comment:
-
Re: Save a Report to Excel
Writing into QuickBooks can be accomplish directly with a read/write QODBC driver.
http://www.qodbc.com
Leave a comment:
Leave a comment: