Skip to main content

Easy Way To Save Excel Data in your Program

Lets face it, everyone still uses Excel for one reason or the other.  I think it's a great tool, especially for organizing and tracking information, creating quick budgets, lists, etc. 

Sometimes at work I get a request for the ability to store Excel data into our database.  For example, we have a QR Scanner that imports data into Excel.  We also have a Scan History table where we store all scans.  Note, we are able to scan traditional bar codes directly into the database, just not the QR Scans.

So, the user wants to copy the scan data into our history database but also assign some other information to it, like a PO Number.  So one of programs I've created is actually pretty simple.

You create a "textarea" input and give it whatever dimensions that seem reasonable.  I also added a Po Number text field for this example. The trick is to separate the data by tabs (but make sure the data itself has no tabs within the cells).  Below is an example of how I separated 3 columns of data, which I then save into the database:

arySkid = split(SONums, chr(13)) 'SONums is the name of the textarea

'reCreate the array b/c there are carriage returns in the front of the skid nos after the first one listed

        for x = 0 to uBound(arySkid)
          if x = 0 then
  SkidNos = trim(arySkid(x)) & ","
  else
  if len(trim(arySkid(x))) > 1 then
     SkidNos = SkidNos & right(trim(arySkid(x)), len(trim(arySkid(x))) - 1) & ","
  end if
  end if
        next

        SkidNos = left(SkidNos, len(SkidNos)-1)

        arySkid = split(SkidNos, ",")

'HERE WE START LOOPING THROUGH EACH PART

for x = 0 to uBound(arySkid)

             xLen = len(trim(arySkid(x))) 'LENGTH OF THE ENTIRE STRING (PART NO AND QTY)
             SpaceStarts = InStr(trim(arySkid(x)), chr(9)) 'SHOWS WHERE TAB STARTS B/W PART NO AND QTY VALUE

             xPartNo = left(trim(arySkid(x)), SpaceStarts-1) 'PART NO VALUE
             xSection2 = right(trim(arySkid(x)), xLen-SpaceStarts) 'second section of data
             xLen2 = len(trim(xSection2))

             SpaceStarts2 = InStr(trim(xSection2), chr(9)) 'SHOWS WHERE the 2nd TAB STARTS B/W serial no and heci

             xSerialNo = left(trim(xSection2), SpaceStarts2-1) 'serial NO VALUE

             xHeci = right(trim(xSection2), xLen2-SpaceStarts2) 'last section of data
         
             'INSERT DATA HERE

next

Comments

Popular posts from this blog

My Twitter Followers Have Gone Down!

If you're a Twitter user you might have heard or seen on your account the number of followers go down.  For some of us, those numbers might be minimal.  I have a Twitter account @NKYSports which I use in connection with one of my High School sports website NKYSports.com.  Last week I had about 6,070 followers.  That number today is down about 100.  But I have heard users who have followers over 50K, 100K, etc. losing thousands and thousands of "so-called" followers.

So what happened?  Twitter has started cleaning accounts due to fake news scandals and data privacy.  That equates to about 1 million accounts the past quarter (2nd Q of 2018).  Twitter CEO Jack Dorsey says improving the health of the platform is critical for future growth.

Twitter has been a great tool for my website, but I also like getting updates sent directly to my phone to get the latest news, sports, weather, etc.  I know what to believe and not to believe as well!  Fake news is every where, always wil…

Book Review: The New Psycho-Cybernetics

The book The New Psycho-Cybernetics by Dr. Maxwell Maltz is truly an amazing book!  This book should be read by everyone!  Whether your self-image is good or bad this book talks about taking steps to improve your self-image, live a longer life, and ultimately be happy!

I myself feel like I have a good self-image, my self-esteem is high and overall I'm an optimistic and happy person.  But I can see how a book like this can help me strive for higher achievements and help me to reach those higher goals!

For those with poor self-images and low esteem this book will benefit you immensely.  The book talks about several examples where people have been down, sick, lonely.  But have gone through the exercises in the book and come out with a much better self-image and becoming much more happy.

There are so many examples in the book its hard to cover them all and that's why I will definitely be reading the book again, as well as a reference for future inspirations.  Towards the end of th…

Love the XMLHttpRequest Object

I was reading up on some XML and AJAX stuff the other day and came across the XMLHttpRequest Object - when I come across snippets of code like the example in the link, I always try to figure a way to incorporate it into my work.  I always ask myself is this something I can use and make my software more efficient?

This was something I most definitely could use as we have a system of part numbers in our database.  We have users that select part numbers to enter Selling Opportunities so I was able to use the code to look up the part numbers more quickly, showing the part numbers, qty on hand, and some other pertinent info.
Below is an example of some code:
Page1.asp
<html> <head> <script> function showHint(str) {     if (str.length == 0) {         document.getElementById("txtHint").innerHTML = "";         return;     } else {         var xmlhttp = new XMLHttpRequest();         xmlhttp.onreadystatechange = function() {             if (this.readyState =…