OpenXMLValidator requires an opened file, but the file won't open - openxml-sdk

I've been struggling with how to fix a SpreadsheetML file being written by a 3rd party library. After some poking about I came across this blog post on OpenXMLValidator. The code is very simple:
Using testdoc As SpreadsheetDocument = SpreadsheetDocument.Open(filepath, False)
Try
Dim validator As New OpenXmlValidator()
Dim count As Integer = 0
For Each [error] As ValidationErrorInfo In validator.Validate(testdoc)
count += 1
Console.WriteLine("Error " & count)
Console.WriteLine("Description: " & [error].Description)
Console.WriteLine("ErrorType: " & [error].ErrorType)
Console.WriteLine("Node: " & [error].Node.ToString())
Console.WriteLine("Path: " & [error].Path.XPath)
Console.WriteLine("Part: " & [error].Part.Uri.ToString())
Console.WriteLine("-------------------------------------------")
Next
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
testdoc.Close()
End Using
One teenie problem, however. When SpreadsheetDocument.Open runs, it throws an error, System.InvalidOperationException: 'Specified part does not exist in the package.' and thus the Validator can't examine it. This is... odd, given that not being able to open the package is precisely the problem I'm trying to solve!
Does anyone have any hints or tricks here? Or perhaps an alternate solution to tracking down OpenXML errors?

Related

Properly Load Microsoft.ML model in Xamarin App?

I was learning a bit about how Machine Learning works and eventually built a small C# application because of a tutorial I was watching where a model determines what species of Bee a particular bee IS. It works well in the C# application, but I was also developing an app project that had picture taking capabilities in mind so I thought "No reason the model I saved in the first project can't work in the second, right?". Apparently there is a reason why it can't work because here is the necessary code to view in the app project:
MLContext m_mlObj;
DataViewSchema m_modelSchema;
ITransformer m_loadedTrainedModel;
var folderPath = DependencyService.Get<IFileSystem>().GetExternalStorage();
var fileDir = Path.Combine(folderPath, "trainedModel.zip");
bool testValue = File.Exists(fileDir);
if(testValue)
{
Console.WriteLine("File in fact exists.");
try
{
m_loadedTrainedModel = m_mlObj.Model.Load(fileDir, out m_modelSchema);
}
catch (Exception e)
{
Console.WriteLine("\n\n\nInner exception: " + e.InnerException);
}
}
else
{
Console.WriteLine("File does not exist");
}
I have a breakpoint on the "m_loadedTrainedModel = m_mlObj.Model.Load(fileDir, out m_modelSchema);" line of course and it always triggers an exception.
The exception states:
---> System.TypeLoadException: Could not load type of field 'Microsoft.ML.Transforms.DnnRetrainTransformer:_tfInputShapes' (9) due to: Could not resolve type with token 01000060 from typeref (expected class 'Tensorflow.TensorShape' in assembly 'TensorFlow.NET, Version=0.20.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:TensorFlow.NET, Version=0.20.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd5 1 type:Tensorflow.TensorShape member:(null)
What I THINK this means is it's checking for Tensorflow.TensorShape inside of the package TensorFlow.NET and isn't finding it. If that's the case, I believe I don't have the correct package installed so my Xamarin project will be able to load the model correctly, maybe? Or if not, then what may be the real underlying issue? The code seems straight forward so I'm a bit perplexed as to how this is failing.
If the solution is blatantly going over my head, my apologies and thank you to anyone who is willing to help.
When working with ML.NET on ARM, TensorFlow is one of the limitations at the time of this writing.
https://devblogs.microsoft.com/dotnet/ml-net-june-updates-model-builder/#ml-net-on-arm
What you might want to consider in the meantime is deploying your model as a Web API and making requests to that API from your mobile app.
https://learn.microsoft.com/dotnet/machine-learning/how-to-guides/serve-model-web-api-ml-net

Syntax error in library code when including matrial design using Rails + Webpacker + Typescript + Angular

In my rails app, I get a syntax error somewhere in a huge js file that is presumably generated by webpacker. But it seems to be some sort of angular/material code. If I don't include material design, the error goes away, so it seems to be related to material design. This is the part that causes the syntax error:
function instantiateSupportedAnimationDriver() {
return !(function webpackMissingModule() { var e = new Error("Cannot find module '#angular/animations/browser'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())() ? new !(function webpackMissingModule() { var e = new Error("Cannot find module '#angular/animations/browser'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())() : new !(function webpackMissingModule() { var e = new Error("Cannot find module '#angular/animations/browser'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())();
}
Note that telling me how to fix the syntax error doesn't help me. This code is not in my control and I wouldn't know how to effectively patch it. Besides, it's a frequently used piece of code, I doubt that it has a syntax error, probably something in plumbing is incorrect.
Some context: I probably don't get all the mechanics right. I am trying to make the combination Rails + Webpacker + Typescript + Angular + Material work. It's quite tricky, I find nothing useful on it on the web and I seem to be pretty much the first one to do it. I saw some suggestions to make an api-only rails app, but I don't like that...
I never really figured out why this caused a syntax error in a seemingly unrelated file, but I had some "unmet peer dependency" warnings and when I fixed them, this went away.

lua lfs on flashair w04 seems not to work

Hi for the last week i have been trying to get my Flashair to upload its files over ftp.
I can make a ftp connection without any problems, but when i try to iterate over the files in its folder its gives me a error on the lua lfs, the only thing its returning is nil.
its goes about this code sample:
for file in lfs.dir(localDir) do
attr = lfs.attributes(localDir .. file)
print( "Found "..attr.mode..": " .. file )
if attr.mode == "file" then
response = fa.ftp("put", ftpString..file, localDir .. file)
if response ~= nil then
print("Success!")
else
print("Fail!")
end
end
end
the error i get is:
lua: ftp.lua:17: attempt to index a nil value (global 'lfs')
stack traceback:
ftp.lua:17: in main chunk
[C]: in ?
where line 17 is the first line in the provided code sample.
Am I missing something, seems that i cannot find a lot information about this problem in combination with the Flashair.
Any help would be appreciated.
I am new to Lua so don't flame me if my response is not beneficial to you. I have been developing an app for W-03 and when testing the Lua app on my MACBOOK linux virtual env I was seeing the same error, and discovered I had to use require "lfs" statement in my test code. require "lfs" is not necessary when running on the actual W-03 though.

save special character in Database using Grails

new Trainingcamp(name:"Höhentraining", region:"Alpen").save()
tr1 = Trainingcamp.findByName("Höhentraining")
tr2 = Trainingcamp.findByRegion("Alpen")
println("Tr1: " + tr1?.name)
println("Tr2: " + tr2?.name)
Output on console is:
Tr1:
Tr2: H?hentraining
So it seems to me that by saving the domainobject something happens that replaces the Special character "ö" with a questionmark "?". How do I get rid of this problem?
Thanks in advanced!
Using Grails 1.3.7
__edit1:
I started the application with prod run-app and then checked the pordDb.log. I found the following insert:
INSERT INTO TRAININGCAMP VALUES('H\ufffdhentraining','Alpen')
No matter I write an "ö" or "ü or "ä" it allways replace it with "\ufffd"
So, any suggestions to solve this problem?
__edit2:
New insight: The Problem only occur when I save the domain in BootStrap.groovy. By saving the domain in a controller the output on the console is as expected:
Tr2: Höhentraining

Add File Summary tab data in runtime in NTFS in WinXP SP3

I have given up tryng to figure out the reason of this issue, but here is the story and hope you could give a tip...
As I develop unique app ( http://code.google.com/p/sedev ) and therefore I need to polish it.
I have to add File Summary ( very useful info in my opinion ) to any created files by the app, so I decided to go with NTFS compatible structure
edit: code snippet in which problem occurs:
if (FileExists(BaseLocation + LeftStr(GetSSWData, Length(GetSSWData)
- 1) + '.vkp') = True) then // add NTFS descriptive information to output file
try
SetFileSummaryInfo
(PWideChar(BaseLocation + LeftStr(GetSSWData, Length
(GetSSWData) - 1) + '.vkp')); // in my testcase files full path is: C:\Documents and Settings\Kludge\Desktop\sedevrpg\SEDEV_RPG_O_710.vkp
ShowMessagePos('Patch Created successfuly!' + #13#13 +
'Please verify created data to www.se-developers.net.',
ParamStr2X, ParamStr3Y);
MessageBeep(0);
except // exception handler does not even fire on exception ...
on Exception do
begin
if (WarningChBx.Checked = True) then
ShowMessagePos
('Unable to add Description to Output file (' +
BaseLocation + LeftStr(GetSSWData, Length(GetSSWData)
- 1) + '.vkp )', ParamStr2X, ParamStr3Y);
MessageBeep(0);
end;
end
final edit by author: Problem was in SetFileSummaryInfo(PWideChar('')) because after PWideChar conversion you got CHARACTER, not Array of Characters ( aka Strings ) therefore it is not valid path anymore!
Here is main tutorial: http://www.delphipages.com/articles/setting_file_summary_information-9228.html
edit: a better formatted tutorial is here.
BUT, the thing is that I just cannot get that damned FileName param to accept any string ... I have EOleSysError exception: "%1 cannot be found" no matter what.
Faulting operand is:
OleCheck(StgOpenStorageEx(PWideChar(FileName),
STGM_SHARE_EXCLUSIVE or STGM_READWRITE,
STGFMT_ANY,
0, nil, nil, #IID_IPropertySetStorage, stg));
What I do not understand is why it actually wants %1 MSDOS file name input.
I am not launching app from CMD therefore I highly doubt it needs additional param for File path ...
I have tried all possible String and PString conversions, also tried various param passing methods ... It just does not work ...
Any help appreciated!
I can only reproduce your case by specifying an invalid filename. Make sure that you include the full path in your filename.

Resources