使用excel生成c ++头文件的宏

时间:2022-10-26 02:04:56

I am thinking to make a excel file which can generate a headre file for my c++ source file. Previoulsy we used to generate .h files using excel but i dont know the logic behind that(Hope some macros using for that).

我想制作一个excel文件,它可以为我的c ++源文件生成一个headre文件。以前我们曾经使用excel生成.h文件,但我不知道背后的逻辑(希望一些宏用于此)。

My header file contains this many data and my intention is to give "MYapp Alpha 0.0.3" through excel file because the version number changes for each release. If I used excel file then I can edit that excel and it creates .h file for me, later some more informations I can make configurable through excel file.

我的头文件包含这么多数据,我的目的是通过excel文件提供“MYapp Alpha 0.0.3”,因为每个版本的版本号都会更改。如果我使用excel文件,那么我可以编辑excel并为我创建.h文件,稍后我可以通过excel文件配置更多信息。

Is it possible to write macro that edit "MYapp Alpha 0.0.3" without touching other

是否可以编写编辑“MYapp Alpha 0.0.3”而无需触及其他内容的宏

 #define APP_FLASH_APP_ID 0x123
 #define APP_VERSION_NUM "MYapp Alpha 0.0.3 "
 #define APP_PRODUCT_NAME "TPI "
 #define APP_DESCRIPTION_STR APP_PRODUCT_NAME APP_VERSION_NUM
 #define APP_RELEASE_DATE_STR "10/11/13"
 #define APP_SOFTWARE_PARTNUM_LEN 10

Some valuable help or suggestions needed

需要一些有价值的帮助或建议

Have a great day

祝你有美好的一天

3 个解决方案

#1


0  

I think this could help you:

我想这可以帮到你:

Sub test()

    Const strVerNumber As String = "0.0.4"

    Dim FS, TSsource
    Set FS = CreateObject("Scripting.FileSystemObject")
    Set TSsource = FS.OpenTextFile("C:\test.txt", 1, 2)

    Dim tmpString As String
    tmpString = TSsource.ReadAll
    TSsource.Close

    tmpString = Replace(tmpString, _
                        "MYapp Alpha 0.0.3", _
                        "MYapp Alpha " & strVerNumber)

    Dim TSout
    Set TSout = FS.Createtextfile("C:\testOUT.txt", True)

    TSout.Write tmpString
    TSout.Close

End Sub

See these methods: OpenTextFile, CreateTextFile, ReadAll and Write

请参阅以下方法:OpenTextFile,CreateTextFile,ReadAll和Write

#2


0  

Are you talking about something like this:

你在谈论这样的事情:

Formulas: 使用excel生成c ++头文件的宏

Results: 使用excel生成c ++头文件的宏

#3


0  

Well basically a .h file is a text file. So you need to do some string processing, open a text file, print the data in it and close it.

基本上.h文件是一个文本文件。因此,您需要进行一些字符串处理,打开文本文件,在其中打印数据并关闭它。

To open and close a text file use this:

要打开和关闭文本文件,请使用以下命令:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Set oFile = fso.CreateTextFile("D:\test.h")
oFile.WriteLine "tfadfadsest"
oFile.Close
Set fso = Nothing
Set oFile = Nothing

#1


0  

I think this could help you:

我想这可以帮到你:

Sub test()

    Const strVerNumber As String = "0.0.4"

    Dim FS, TSsource
    Set FS = CreateObject("Scripting.FileSystemObject")
    Set TSsource = FS.OpenTextFile("C:\test.txt", 1, 2)

    Dim tmpString As String
    tmpString = TSsource.ReadAll
    TSsource.Close

    tmpString = Replace(tmpString, _
                        "MYapp Alpha 0.0.3", _
                        "MYapp Alpha " & strVerNumber)

    Dim TSout
    Set TSout = FS.Createtextfile("C:\testOUT.txt", True)

    TSout.Write tmpString
    TSout.Close

End Sub

See these methods: OpenTextFile, CreateTextFile, ReadAll and Write

请参阅以下方法:OpenTextFile,CreateTextFile,ReadAll和Write

#2


0  

Are you talking about something like this:

你在谈论这样的事情:

Formulas: 使用excel生成c ++头文件的宏

Results: 使用excel生成c ++头文件的宏

#3


0  

Well basically a .h file is a text file. So you need to do some string processing, open a text file, print the data in it and close it.

基本上.h文件是一个文本文件。因此,您需要进行一些字符串处理,打开文本文件,在其中打印数据并关闭它。

To open and close a text file use this:

要打开和关闭文本文件,请使用以下命令:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Set oFile = fso.CreateTextFile("D:\test.h")
oFile.WriteLine "tfadfadsest"
oFile.Close
Set fso = Nothing
Set oFile = Nothing