nht3004 Posted May 3, 2009 Share Posted May 3, 2009 (edited) I want to export an INI file to an Excel file, what should I do? I have an INIFile: [Student number 1] ID=1; Score=9; [Student number 2] ID=2; Score=10; And an excel page should be: Name ID Score Student Number 1 1 9 Student Number 2 2 10 Thanks Edited May 3, 2009 by nht3004 for(loop=0; loop<infinity; loop++) { alert('I love you'); } Link to comment Share on other sites More sharing options...
MrMitchell Posted May 3, 2009 Share Posted May 3, 2009 Read from INI, write to Excel. Take it a step at a time. Why don't you post what code you have so far? Might want to #include <Excel.au3> too. Link to comment Share on other sites More sharing options...
nht3004 Posted May 3, 2009 Author Share Posted May 3, 2009 Read from INI, write to Excel. Take it a step at a time.Why don't you post what code you have so far? Might want to #include <Excel.au3> too.I thought of it but I dont know how to write to an Excel, do you mean open an excel an use SEND(KEY)? for(loop=0; loop<infinity; loop++) { alert('I love you'); } Link to comment Share on other sites More sharing options...
Quual Posted May 3, 2009 Share Posted May 3, 2009 Do you know how to use VBA in excel ? If so, accessing the .ini files and filling cells with the data via VBA would be a lot easier than doing it with AutoIt. Here are some simple VBA functions to read/write .ini files. Paste the following code into its own module. expandcollapse popupPrivate Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" _ (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _ (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, _ ByVal nSize As Long, ByVal lpFileName As String) As Long Private Declare Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" _ (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _ (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long '------------------- 'reads ini string Public Function ReadIni(filename As String, section As String, key As String) As String Dim RetVal As String * 255, v As Long v = GetPrivateProfileString(section, key, "", RetVal, 255, filename) ReadIni = Left(RetVal, v) End Function 'reads ini section Public Function ReadIniSection(filename As String, section As String) As String Dim RetVal As String * 255, v As Long v = GetPrivateProfileSection(section, RetVal, 255, filename) ReadIniSection = Left(RetVal, v - 1) End Function 'writes ini Public Sub WriteIni(filename As String, section As String, key As String, value As String) WritePrivateProfileString section, key, value, filename End Sub 'writes ini section Public Sub WriteIniSection(filename As String, section As String, value As String) WritePrivateProfileSection section, value, filename End Sub If you have no experience with VBA I suggest using Autoit to read the .ini files and export the data as a csv (comma seperated values] file. Name,ID ,Score Student Number 1,1,9 Student Number 2,2,10 Excel can import a cvs file directly into a worksheet. (file - open - change files of type dropdown to Txt (*.cvs) and select the file. Link to comment Share on other sites More sharing options...
darzanmihai Posted May 3, 2009 Share Posted May 3, 2009 I thought of it but I dont know how to write to an Excel, do you mean open an excel an use SEND(KEY)?you can use the excel UDF...it is very simple : http://www.autoitscript.com/forum/index.ph...xcelCOM_UDF.au3mihai I do not like stupid and idiot people that write idiot things...If you are one, do not write. Link to comment Share on other sites More sharing options...
MrMitchell Posted May 3, 2009 Share Posted May 3, 2009 If you have no experience with VBA I suggest using Autoit to read the .ini files and export the data as a csv (comma seperated values] file.Name,ID ,ScoreStudent Number 1,1,9Student Number 2,2,10Excel can import a cvs file directly into a worksheet. (file - open - change files of type dropdown to Txt (*.cvs) and select the file.I like this approach, it would be very easy and you don't have to touch Excel UDF. You could use IniReadSectionNames then for each element of that you can use IniReadSection and write to a CSV. Link to comment Share on other sites More sharing options...
nht3004 Posted May 3, 2009 Author Share Posted May 3, 2009 Thanks alot, I'll try all the way you tell me ^^! for(loop=0; loop<infinity; loop++) { alert('I love you'); } Link to comment Share on other sites More sharing options...
MrMitchell Posted May 3, 2009 Share Posted May 3, 2009 (edited) Any luck? Edited May 3, 2009 by MrMitchell Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now