Author Topic: how to import data from excel HELP!  (Read 6380 times)

scottbux

  • Newbie
  • *
  • Posts: 2
how to import data from excel HELP!
« on: August 03, 2011, 01:16:39 AM »
im trying to import data from excel. i have no idea how to do it. i have read through the entire quick start guide and searched through all the forums but i cant find anything. the closest thing to an answer i have found says to check out the books project. but from what i understand that just saves data you type into the software.  here is an example of what i need.

Phone Number            Customer Name            Account Info
 "Data from cell A"        "Data from cell B"         "Data from cell C"


    Notes: "whatever notes the employee writes"

Then i need to know how to save data (like data put into the notes field) into a different excel file.  i pretty much have the rest of the software made i just need this very important detail. i have never programmed any kind of software before so all of this is new to me. so please explain it like you're talking to a 7 year old :)

oh and one more thing. i need to know how to password protect my software. so new users would have to enter their own custom username and password. Please help!

Scott
« Last Edit: August 03, 2011, 01:18:14 AM by scottbux »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 461
  • Here to help you
Re: how to import data from excel HELP!
« Reply #1 on: August 03, 2011, 05:36:08 PM »
im trying to import data from excel. i have no idea how to do it. i have read through the entire quick start guide and searched through all the forums but i cant find anything. the closest thing to an answer i have found says to check out the books project. but from what i understand that just saves data you type into the software.  here is an example of what i need.

Phone Number            Customer Name            Account Info
 "Data from cell A"        "Data from cell B"         "Data from cell C"


    Notes: "whatever notes the employee writes"

Then i need to know how to save data (like data put into the notes field) into a different excel file.  i pretty much have the rest of the software made i just need this very important detail. i have never programmed any kind of software before so all of this is new to me. so please explain it like you're talking to a 7 year old :)

Sorry, I'm so tired I feel like a 5 year old :)

Your Excel needs saving in CSV format - and as a basic Excel file, not with Workbook.

Here is some code that would readin data from an Excel file and place it in a field so its format could be examined - it is from this post:-

http://www.tigabyte.com/smf/index.php?topic=91.msg324#msg324


Code: [Select]
@Read from a named file, assumes format known
Local fname,fvar,fdets,ftypes,fpaths,fnames,fextens
Local findex,fend

local comma,mess

@ delimiter
Put ',' into comma

@ File name
Put 'comicbook1.csv' into fname

FileGet(fname,fvar,fdets,ftypes,fpaths,fnames,fextens)
OpenAsBFile(fvar,findex)

@ ++ loop over file until no data remaining +++
Put EndBFileFN(findex) into fend
While (fend<>1)
    ReadBVariable(findex,mess)
    if mess$<>comma then
        Put mess after field 2
    EndIf
    Put EndBFileFN(findex) into fend
EndWhile

CloseBFile(findex)





About saving your data to an Excel file - i'm not sure how to get the exact layout you require in terms of cell placement.

Here is a post with some code for saving to a CSV format:-

http://www.tigabyte.com/smf/index.php?topic=14.msg281#msg281


and here is the relevant code from that post:-

Code: [Select]
@ Write to a named file
Local fname,fvar,fdets,ftypes,fpaths,fnames,fextens
Local findex,n
Local comma,char

@ delimiter
Put ',' into comma

@ File name
Put 'test1.csv' into fname

@ Create and open file
FileGet(fname,fvar,fdets,ftypes,fpaths,fnames,fextens)
CreateBFile(fvar,findex,n)

@ Write data to file
WriteBVariable(findex,'hello')
WriteBVariable(findex,comma)

WriteBVariable(findex,'how are you')
WriteBVariable(findex,comma)

WriteBVariable(findex,'today')

@ Close file
CloseBFile(findex)





oh and one more thing. i need to know how to password protect my software. so new users would have to enter their own custom username and password. Please help!

Yes you can password to prevent unauthorised users looking at other cards and info. Here is one post on it:-

http://www.tigabyte.com/smf/index.php?topic=82.msg246#msg246



On your home card or another suitable card put one button and two fields where field 1 holds the name and field 2 holds the password. Place this code in the login button

Code: [Select]
Local name,password

Put field 1 into name

Put field 2 into password

If (name$=’John Smith’) and (password$=’1234’) then
   GotoCard 2
else
  Message ‘Invalid”
Endif


In a working program you would store the names and passwords in a list using “Put after”. Here is some code (not tested) that shows the basic idea for seeing if a name and password is in the lists. Place this code in the login button

Code: [Select]
Global nameList,passwordList
Local name1,password1,name2,password2,n,count

Put field 1 into name1
Put field 2 into password1


Put LinesFN(namesList) into count
if count>0 then
   for n=1 to count
      put line n of nameList into name2
      if name2$=name1 then
          put line n of passwordList into password2
          if (password2$=password1) then
             GotoCard 2
          endif
      Endif
  endfor
EndIf

Message ‘Invalid attempt’


Malkom

I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

scottbux

  • Newbie
  • *
  • Posts: 2
Re: how to import data from excel HELP!
« Reply #2 on: August 06, 2011, 10:36:23 AM »
wow thanks for the quick response. so....nothing worked. i copied the first code you gave me and switched out the file name "comicbook1.csv" to the one im using. it just copies all of the data into  one field (name, phone number ect.) so how do i make it transfer the data from specific cells to specific fields?

i also tried the password code you gave me but to no avail. i copied and pasted the code to the sign in button, but when i push "Run" the Compile screen and little Cards progress bar come up and the  green progress bar gets about a fifth of the way there and just stops. ive tried just waiting it out (like 15 minutes) but no progress. so i figured i should try uninstalling hypernext and reinstalling but the same thing still happens. any ideas?

i havent tried using the save to csv code you gave me yet. i figure i'll cross that bridge after i can imput data first.

thanks,
   Scott

 

anything