Yeah I guess I would have to familiarize myself with the export macro. But as long as it works I would be more than happy and over the moon! It would make my life so much easiermak_kawa wrote: ↑August 28th, 2020, 1:22 pm Hi JP2K
The export macro saves csv file having the same base name along with Excel file. So, you can of course edit Excel file after export, and when save updated Excel file, CSV file is again exported/updated.
And... the export macro is somewhat complicated if you are not familiar for Excel VBA. Is it OK?
But actually... for my Rainmeter skill, 2. Parse the CSV file using WebParser measure. seems to have some difficulty unless the source data has fixed Rows/Columns... my thought is possibly not enough, sorry. Maybe someone will present better idea...
It is currently April 26th, 2024, 11:35 am
Using Excel as a Rainmeter Skin
-
- Posts: 16
- Joined: August 28th, 2020, 10:56 am
Re: Using Excel as a Rainmeter Skin
-
- Rainmeter Sage
- Posts: 7170
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
-
- Rainmeter Sage
- Posts: 7170
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Using Excel as a Rainmeter Skin
Yeah, folks, don't worry about parsing the CSV, I'll handle that if needed and no one else does it in the meantime, I'm not afraid of some regex, LOL - but a bit later on. Like jsmorley said, it's quite easy: rows are separated by \n aka new lines and columns are separated by either , or ; (I think the latter depends on the locale formatting). Just do the macro part and half the job is done. I could take a look at that, of course, but I have other projects at the moment as well, so maybe later today.
-
- Developer
- Posts: 22630
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Using Excel as a Rainmeter Skin
Checking the file date would look like this:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
FileDate=13243082434
[MeasureFolder]
Measure=Plugin
Plugin=FileView
Path=#CURRENTPATH#
ShowDotDot=0
ShowFolder=0
WildcardSearch=mySpreadsheet.csv
Count=1
UpdateDivider=10
OnUpdateAction=[!CommandMeasure MeasureFolder "Update"]
[MeasureDate]
Measure=Plugin
Plugin=FileView
Path=[MeasureFolder]
Type=FileDate
DynamicVariables=1
IfCondition=[MeasureDate:] > #FileDate#
IfTrueAction=[!Log "New Version!"][!SetVariable FileDate "[MeasureDate:]"][!WriteKeyValue Variables FileDate "[MeasureDate:]"]
[MeterDate]
Meter=String
MeasureName=MeasureDate
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
-
- Developer
- Posts: 22630
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Using Excel as a Rainmeter Skin
To each his own, but I would SO use Lua for this... It's going to be much more straightforward to get all the rows and columns into a table, and parse it out based on "newest" or whatever criteria you want. Lua is just particularly good at this kind of data. A "table" in Lua actually is more or less a spreadsheet.
I would use WebParser to get the entire file into one string with RegExp=^(.*)$, then get the value of that measure in Lua to do the parsing and either using Inline Lua to display the results, or just SKIN:Bang("!SetOption",...) to set Text values on meters.
I would use WebParser to get the file contents, rather than directly reading the file with Lua, to avoid issues with Unicode.
I would use WebParser to get the entire file into one string with RegExp=^(.*)$, then get the value of that measure in Lua to do the parsing and either using Inline Lua to display the results, or just SKIN:Bang("!SetOption",...) to set Text values on meters.
I would use WebParser to get the file contents, rather than directly reading the file with Lua, to avoid issues with Unicode.
-
- Posts: 16
- Joined: August 28th, 2020, 10:56 am
Re: Using Excel as a Rainmeter Skin
I just want to let you all know how grateful i am to everyone helping out with this project! It really means the world to me! such a great community!
You guys are truly awesome!
You guys are truly awesome!
-
- Rainmeter Sage
- Posts: 7170
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Using Excel as a Rainmeter Skin
Yep, understandable. It's the kind of tasks Lua can help Rainmeter with. Would add here automatically parsing JSON files as well. However, for this little task, I'll use native code - I'll keep in mind the Lua option from the link dvo provided though, just in case.jsmorley wrote: ↑August 28th, 2020, 2:17 pm To each his own, but I would SO use Lua for this... It's going to be much more straightforward to get all the rows and columns into a table, and parse it out based on "newest" or whatever criteria you want. Lua is just particularly good at this kind of data. A "table" in Lua actually is more or less a spreadsheet.
I would use WebParser to get the entire file into one string with RegExp=^(.*)$, then get the value of that measure in Lua to do the parsing and either using Inline Lua to display the results, or just SKIN:Bang("!SetOption",...) to set Text values on meters.
I would use WebParser to get the file contents, rather than directly reading the file with Lua, to avoid issues with Unicode.
That being said, I'm not even sure parsing the file is needed. I guess you could just replace , or ; with TAB characters and display it like that. Or, just save the Excel workbook as tab delimited text. The idea is to display the contents in a clear and simple manner, and that makes things easier.
By the way, I have the macro part done in VBA.
-
- Rainmeter Sage
- Posts: 7170
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Using Excel as a Rainmeter Skin
JP2K wrote: ↑August 28th, 2020, 11:02 amI was hoping, to increase my productivity, that i could use Excel as a Rainmeter Skin. Basically using it as a Background and every time i save my excel.xlsx file it would update my background with the same spreadsheet as well. so creating a link between rainmeter and the file. is that possible?
jsmorley wrote: ↑August 28th, 2020, 2:17 pmTo each his own, but I would SO use Lua for this... It's going to be much more straightforward to get all the rows and columns into a table, and parse it out based on "newest" or whatever criteria you want. Lua is just particularly good at this kind of data. A "table" in Lua actually is more or less a spreadsheet.
Ok, so following the excellent suggestions by mak_kawa and jsmorley and some bits from my parts, here it is the result (nothing to worry about creating tables, rows and columns, as long as you only want to display the file contents - if you want to have hundreds of meters for each cell from the Excel file and manipulate them, don't count on me, as I like being compact about things). By the way, this works with both CSV and TAB delimited TXT...
Skin: Skin Code:
Code: Select all
[Variables]
FilePath=F:\Wireless\
FileName=Book1.csv
FileDate=13243119723
EvenColColor=255,128,64,255
OddColColor=64,255,128,255
BackColor=0,0,0,64
FontFace=Consolas
FontSize=12
Padding=5
TrailingSpaces=" "
TrailingSpacesCount=10
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
---Measures---
[MeasureFolder]
Measure=Plugin
Plugin=FileView
Path="#FilePath#"
ShowDotDot=0
ShowFolder=0
WildcardSearch="#FileName#"
Count=1
UpdateDivider=10
OnUpdateAction=[!CommandMeasure MeasureFolder "Update"]
[MeasureDate]
Measure=Plugin
Plugin=FileView
Path=[MeasureFolder]
Type=FileDate
IfCondition=([MeasureDate:]>#FileDate#)
IfTrueAction=[!SetVariable FileDate "[MeasureDate:]"][!WriteKeyValue Variables FileDate "[MeasureDate:]"][!CommandMeasure MeasureFile "Update"]
DynamicVariables=1
[MeasureFile]
Measure=WebParser
URL="file://#FilePath##FileName#"
RegExp=(?siU)^(.*)$
RegExpSubstitute=1
Substitute="([\t,])":"#TrailingSpaces#[\x0009]","(.{#TrailingSpacesCount#}).*?(\t)":"\1\2"
DynamicVariables=1
---Meters---
[MeterFile]
Meter=String
MeasureName=MeasureFile
FontFace=#FontFace#
FontSize=#FontSize#
FontWeight=400
FontColor=#OddColColor#
SolidColor=#BackColor#
StringEffect=Shadow
FontEffectColor=0,0,0,255
Padding=#Padding#,#Padding#,#Padding#,#Padding#
AntiAlias=1
InlineSetting=Color | #EvenColColor#
InlinePattern=[^\t]*\t+([^\t]*\t+)
Text="%1"
DynamicVariables=1
Code: Select all
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim SourceWB As Workbook, DestWB As Workbook
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
Set SourceWB = ActiveWorkbook
ActiveSheet.Copy
Set DestWB = ActiveWorkbook
DestWB.SaveAs Filename:=Left(SourceWB.FullName, (InStr(SourceWB.FullName, ".") - 1)) + ".csv", FileFormat:=xlCSV, ConflictResolution:=xlLocalSessionChanges
DestWB.SaveAs Filename:=Left(SourceWB.FullName, (InStr(SourceWB.FullName, ".") - 1)) + ".txt", FileFormat:=xlTextWindows, ConflictResolution:=xlLocalSessionChanges
DestWB.Close SaveChanges:=False
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub
Obviously, the FilePath and FileName variables should be adjusted to your needs (the path must contain a \ at the end) and the TrailingSpacesCount value should match the number of spaces in TrailingSpaces (the latter two control the width of a "column"). I had to use this trick, along with setting a monospaced font for the text (strongly recommended in this implementation) because it's the only way to "align" things automatically in "columns", as characters have the same width. I could have let just the TAB characters instead, but what happened is that there was only one TAB between values and for longer values the "table simulation" here would have become a bit messy as the length of the longer text would have exceeded the length of the other texts and their trailing TABs from the same column but different rows. There was also the option of actually parsing the file using either native code or Lua in order to create a meter for each cell, but as I said, having hundreds of meters in the skin was not a job for me, LOL.
Bear in mind that CSV and TXT would not work with multiple sheet workbooks, as far as I know. Also, make sure you save your workbook as Macro-Enabled Workbook (XLSM) in order to have the macro available (or you could just copy the samples above instead).
Feel free to adjust things from the [Variables] section - the names of the variables are self-explanatory, but if you need more info, just ask.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 16
- Joined: August 28th, 2020, 10:56 am
Re: Using Excel as a Rainmeter Skin
This is soooo cool! thanks a bunch! i do have a question. So the macro. what menu do i have to open? is it the menu folder of rainmeter or excel? and how do i get to it? Also does skin support highlighting? that would be a very important feature for organizing you are amazing dude!Yincognito wrote: ↑August 28th, 2020, 5:47 pm Ok, so following the excellent suggestions by mak_kawa and jsmorley and some bits from my parts, here it is the result (nothing to worry about creating tables, rows and columns, as long as you only want to display the file contents - if you want to have hundreds of meters for each cell from the Excel file and manipulate them, don't count on me, as I like being compact about things). By the way, this works with both CSV and TAB delimited TXT...
Skin:
Excel_1.0.0.rmskin
Skin Code:Macro (go to Menu / Developer / View Code, right click ThisWorkbook / View Code and paste the below - remove the appropriate SaveAs line to only save to CSV or TXT):Code: Select all
[Variables] FilePath=F:\Wireless\ FileName=Book1.csv FileDate=13243119723 EvenColColor=255,128,64,255 OddColColor=64,255,128,255 BackColor=0,0,0,64 FontFace=Consolas FontSize=12 Padding=5 TrailingSpaces=" " TrailingSpacesCount=10 [Rainmeter] Update=1000 DynamicWindowSize=1 AccurateText=1 ---Measures--- [MeasureFolder] Measure=Plugin Plugin=FileView Path="#FilePath#" ShowDotDot=0 ShowFolder=0 WildcardSearch="#FileName#" Count=1 UpdateDivider=10 OnUpdateAction=[!CommandMeasure MeasureFolder "Update"] [MeasureDate] Measure=Plugin Plugin=FileView Path=[MeasureFolder] Type=FileDate IfCondition=([MeasureDate:]>#FileDate#) IfTrueAction=[!SetVariable FileDate "[MeasureDate:]"][!WriteKeyValue Variables FileDate "[MeasureDate:]"][!CommandMeasure MeasureFile "Update"] DynamicVariables=1 [MeasureFile] Measure=WebParser URL="file://#FilePath##FileName#" RegExp=(?siU)^(.*)$ RegExpSubstitute=1 Substitute="([\t,])":"#TrailingSpaces#[\x0009]","(.{#TrailingSpacesCount#}).*?(\t)":"\1\2" DynamicVariables=1 ---Meters--- [MeterFile] Meter=String MeasureName=MeasureFile FontFace=#FontFace# FontSize=#FontSize# FontWeight=400 FontColor=#OddColColor# SolidColor=#BackColor# StringEffect=Shadow FontEffectColor=0,0,0,255 Padding=#Padding#,#Padding#,#Padding#,#Padding# AntiAlias=1 InlineSetting=Color | #EvenColColor# InlinePattern=[^\t]*\t+([^\t]*\t+) Text="%1" DynamicVariables=1
Sample Workbooks (odd and even column count):Code: Select all
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim SourceWB As Workbook, DestWB As Workbook Application.ScreenUpdating = False Application.EnableEvents = False Application.DisplayAlerts = False Set SourceWB = ActiveWorkbook ActiveSheet.Copy Set DestWB = ActiveWorkbook DestWB.SaveAs Filename:=Left(SourceWB.FullName, (InStr(SourceWB.FullName, ".") - 1)) + ".csv", FileFormat:=xlCSV, ConflictResolution:=xlLocalSessionChanges DestWB.SaveAs Filename:=Left(SourceWB.FullName, (InStr(SourceWB.FullName, ".") - 1)) + ".txt", FileFormat:=xlTextWindows, ConflictResolution:=xlLocalSessionChanges DestWB.Close SaveChanges:=False Application.ScreenUpdating = True Application.EnableEvents = True Application.DisplayAlerts = True End Sub
Book1.xlsm
Book1.xlsm
Preview (odd column count):
Excel - Odd Columns.jpg
Preview (even column count):
Excel - Even Columns.jpg
Nice effects, right? Say thanks to InlineSettings for that.
Obviously, the FilePath and FileName variables should be adjusted to your needs (the path must contain a \ at the end) and the TrailingSpacesCount value should match the number of spaces in TrailingSpaces (the latter two control the width of a "column"). I had to use this trick, along with setting a monospaced font for the text (strongly recommended in this implementation) because it's the only way to "align" things automatically in "columns", as characters have the same width. I could have let just the TAB characters instead, but what happened is that there was only one TAB between values and for longer values the "table simulation" here would have become a bit messy as the length of the longer text would have exceeded the length of the other texts and their trailing TABs from the same column but different rows. There was also the option of actually parsing the file using either native code or Lua in order to create a meter for each cell, but as I said, having hundreds of meters in the skin was not a job for me, LOL.
Bear in mind that CSV and TXT would not work with multiple sheet workbooks, as far as I know. Also, make sure you save your workbook as Macro-Enabled Workbook (XLSM) in order to have the macro available (or you could just copy the samples above instead).
Feel free to adjust things from the [Variables] section - the names of the variables are self-explanatory, but if you need more info, just ask.
-
- Rainmeter Sage
- Posts: 7170
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Using Excel as a Rainmeter Skin
It's the menu (not the "menu folder" - I don't even know what that is) of Excel, see here for details.JP2K wrote: ↑August 28th, 2020, 5:57 pm This is soooo cool! thanks a bunch! i do have a question. So the macro. what menu do i have to open? is it the menu folder of rainmeter or excel? and how do i get to it? Also does skin support highlighting? that would be a very important feature for organizing you are amazing dude!
I would have thought that using Excel you would have known that already...Macro (go to Menu / Developer / View Code, right click ThisWorkbook / View Code and paste the below - remove the appropriate SaveAs line to only save to CSV or TXT):
What you mean by highlighting though? Coloring the background of the text to indicate that is "selected" or "active" or something else? If you talk about this, no, this implementation doesn't support highlighting (as in coloring the background of the text selectively) since the InlineSetting option can't control the SolidColor of the text background, but you can color the text itself as desired. For that, you'd have to create an appropriate InlineSetting / InlinePattern pair to do that, see more about it here (you can try or change the sample skin at the bottom to understand how it works).
Or, you can ask jsmorley do do his Lua thing and help you create a "customized" skin for that. I'm more of a "one size fits all" kind of guy, as long as the solution is adaptable and tweakable for use in various scenarios.
Glad you liked my solution though - hopefully it will help you as much as you want to.