1 страниц (8 вхождений)
[XlsxImportExport] File open errors - Can not find referenced files on workbook opening - Сообщения
#1 Опубликовано: 21.02.2019 18:47:11
Hi all-
I get this odd behavior opening files from either the recent file menu or by double clicking the SMath file in Explorer.
SMATH thinks the current directory is C:\Windows\.... and therefore it can not find the files I am trying to read in.
Its not consistent, but when it starts happening, I 'fix' it by either: deleting the CurrenDirectory("") and re-writing it, saving the file as the same name or slightly modified file name in the SAME directory, or by signing off or rebooting.
I can not figure out if this is a Windows issue or an SMath issue. And now that I think about it, its almost always a referenced spreadsheet, but that is usually what I am bringing in.
I can not figure out what else to attach or debug info might be helpful. I tried searching but couldn't find anything.
Dennis
I get this odd behavior opening files from either the recent file menu or by double clicking the SMath file in Explorer.
SMATH thinks the current directory is C:\Windows\.... and therefore it can not find the files I am trying to read in.
Its not consistent, but when it starts happening, I 'fix' it by either: deleting the CurrenDirectory("") and re-writing it, saving the file as the same name or slightly modified file name in the SAME directory, or by signing off or rebooting.
I can not figure out if this is a Windows issue or an SMath issue. And now that I think about it, its almost always a referenced spreadsheet, but that is usually what I am bringing in.
I can not figure out what else to attach or debug info might be helpful. I tried searching but couldn't find anything.
Dennis
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#2 Опубликовано: 21.02.2019 19:03:08
#3 Опубликовано: 21.02.2019 19:09:24
I found in a snippet of mine where I import an excel file, I did something like below.
1. Save document directory location.
2. Change directory location to file I want to import.
3. Import sheets
4. return current directory to document directory.
I don't know why I did it like this as I made it years ago, but maybe I ran into a similar issue.
1. Save document directory location.
2. Change directory location to file I want to import.
3. Import sheets
4. return current directory to document directory.
I don't know why I did it like this as I made it years ago, but maybe I ran into a similar issue.
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#4 Опубликовано: 21.02.2019 20:44:57
If you remove/disable CurrentDirectory() before opening the worksheet, importData.XLSX doesn't works as it should?
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#5 Опубликовано: 22.02.2019 20:29:13
I don't think this is an excel plugin issuse, this is a file handling issue with SMATH.
The reason I am trying to be explicit in the directory and filename is I have the necessary job/project specific reference files in one 'local' directory and the global reference files in another 'network drive' directory location. I am trying to force SMATH to only read and write out to the local directory.
I copy and paste the template files from the network folder to the local job/project folder.
Then when I open the local files, it would read and write back to the network one.
When I try to use the File menu ->Properties it shows the right location.
If there is a better way to enforce file locations, I am all ears.
Dennis
The reason I am trying to be explicit in the directory and filename is I have the necessary job/project specific reference files in one 'local' directory and the global reference files in another 'network drive' directory location. I am trying to force SMATH to only read and write out to the local directory.
I copy and paste the template files from the network folder to the local job/project folder.
Then when I open the local files, it would read and write back to the network one.
When I try to use the File menu ->Properties it shows the right location.
If there is a better way to enforce file locations, I am all ears.
Dennis
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#6 Опубликовано: 23.02.2019 08:19:09
I think I fixed it (XlsxImportExport plugin updated). The error occours because you have the excel file open by another process; this was related to a fix introduced with the no more used ClosedXML library.
About the directories:
About the directories:
- CurrentDirectory() shows a known issue about Environment.CurrentDirectory not updated in SMathStudio while you change worksheets (I'll check it later on SS side);
- DocumentDirectory() rely on Store.FileName, that should works correctly. If you want to build absolute paths, you should use this as root;
- importData.XLSX() rely on Store.FileName too for relative paths, thus either if you use relative paths or you build absolute ones using DocumentDirectory() the result is the same.
- once you pass an absolute path to importData.XLSX() anything else doesn't matter whatever is the behavior of CurrentDirectory() or DocumentDirectory()
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
2 пользователям понравился этот пост
#7 Опубликовано: 27.02.2019 14:52:26
Davide-
Yes, I probably have that spreadsheet open as I am working. I did not think it was an issue. I will try it with it closed.
If I do not explicitly define the filenames, then when I copy the files as templates, SMATH seems to remember the origins and relative paths from the origin. So the 'child' SMath sheet finds the 'parent' SiteData spreadsheet.
The referenced include statement, which is obscured in my original post, is pointing back to the 'parent' location of the templates too. Perhaps that is part of the issue?
Even if I open it from the File Menu -> Recent Files -> entry, it opens with the wrong CurrentDirectory().
Then when I go to save it, SMath seems to remember the last directory that I was working in.
Are these both symptoms of the issues you referenced? Is it the same error reported in the newer thread?
See screens below.


Yes, I probably have that spreadsheet open as I am working. I did not think it was an issue. I will try it with it closed.
If I do not explicitly define the filenames, then when I copy the files as templates, SMATH seems to remember the origins and relative paths from the origin. So the 'child' SMath sheet finds the 'parent' SiteData spreadsheet.
The referenced include statement, which is obscured in my original post, is pointing back to the 'parent' location of the templates too. Perhaps that is part of the issue?
Even if I open it from the File Menu -> Recent Files -> entry, it opens with the wrong CurrentDirectory().
Then when I go to save it, SMath seems to remember the last directory that I was working in.
Are these both symptoms of the issues you referenced? Is it the same error reported in the newer thread?
See screens below.
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#8 Опубликовано: 28.02.2019 06:21:24
WroteYes, I probably have that spreadsheet open as I am working. I did not think it was an issue. I will try it with it closed.
Now it should works even if the file is open, or should give a different error.
WroteIf I do not explicitly define the filenames, then when I copy the files as templates, SMATH seems to remember the origins and relative paths from the origin. So the 'child' SMath sheet finds the 'parent' SiteData spreadsheet.
The referenced include statement, which is obscured in my original post, is pointing back to the 'parent' location of the templates too. Perhaps that is part of the issue?
Even if I open it from the File Menu -
The problem with built-in importData and maybe some plugins is that if you are using relative paths and they rely directly on the framework functions, these are using the "Current Directory" to resolve relative paths. XLSX import/export, DataExchange, WriterRegion, are "aware" of this potential issue and for relative paths they rebuild a rooted path internally.
The parent location was pointed because you started your smath session there, then you opened the child in the same session (it is a bug, not your fault).
In short actually you might experience issues:
- if in the same SMath Studio instance you open different sm worksheets in different locations;
- if under the first circumstance you are using relative paths on built-in importData() or some other function that rely directly on framework filesystem functions;
- if under the first circumstance you are using absolute paths created on the fly in the worksheet with CurrentDirectory()
These are all unrelated with the original issue in this thread "Could not find a part of the path ..." that should be solved and was related to XLSX import/export and Data Exchange plugins only. I'll mark this as solved, for the discussion about the wrong "Current Directory" we can use this other thread.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
2 пользователям понравился этот пост
1 страниц (8 вхождений)
-
Новые сообщения
-
Нет новых сообщений