Results 1 to 3 of 3

Thread: receipt printing

  1. #1
    jsj1411 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    May 2012
    Posts
    3
    Reputation
    0

    Exclamation receipt printing

    hey guys , i need some help and guidance regarding my college project. i'm working on a sales system . i have a form which consist of all the following information( item code , item name , item price , quantity of item ) which is display using a data grid . data input by user using text box and all this information will be stored in a database(sales database) i'm using ms access 2007. the grand total will be displayed in a text box . and amount paid will be input in a text box too , my major problem now is how to i create a reciept that will have all this information of the purcase. i have a reciept button . what the next step ? i dont have any idea how to get the reciept done.

    thanks guys

  2. #2
    aeskan is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2011
    Posts
    54
    Reputation
    25
    One of the solutions is:


    1. Add > Microsoft Excel 14.0 Object Library to
    your project's references
    2. Make your receipt form as you wish in
    Excel and save it for example as "Template1.Xlsx" for the further use
    3. Write the following codes to print your database

    PrivateSub Do_Print()

    Dim oExcel AsObject = GetObject("", "Excel.Application")
    Dim oBook AsObject = oExcel.Workbooks.Open("D:\Template1.Xlsx")
    Dim oSheet AsObject = oBook.Worksheets(1)

    oSheet.PageSetup.CenterHeaderPicture.FileName = logoFile
    'if is necessary
    oSheet.PageSetup.CenterHeader = "&G"'if is necessary
    oSheet.PageSetup.HeaderMargin = 30 'if is necessary
    'fill Excel sheet cells here with your data
    oSheet.Range("B3").Value = itemCode

    oSheet.Range(
    "B6").Value = itemName
    oSheet.Range(
    "D10").Value = itemPrice

    'and other items
    'finally save, close and print Excel file
    oSheet.PageSetup.PrintArea = "$A$1:$K$67" 'makes your print area

    oBook.SaveAs("D:\Receipt.Xlsx")
    oSheet.PrintOut() 'print command
    oBook.close()
    oExcel.Quit()
    System.Runtime.InteropServices.Marshal.ReleaseComO bject(oExcel)
    oExcel =
    Nothing
    Kill("D:\Receipt.Xlsx") 'deletes the file

    EndSub

    Have a nice print
    Last edited by aeskan; 05-27-2012 at 7:02 PM.

  3. #3
    aeskan is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2011
    Posts
    54
    Reputation
    25
    Note: If it was useful for you, for more information and help about VB functions for Excel, active your Excel Developer menu tab and then open Visual Basic Editor there in Excel, And fallow it's Help.
    Last edited by aeskan; 05-27-2012 at 8:22 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking