Hi I was wondering if it was possible to import data from a xls file into
Unity, and use this with vuforia and c# scripting to be able to track words from the xls file and display there corresponding values from the spread sheet.
I could simply copy the words into a white list to be able to track them, but then how would I go about using this to display each rows information.
To clarify slightly, I have a spreadsheet of car names and there sale prices and mileage. I would want to track the car name and be able to display the price and mileage on screen.
Any point in the right direction would be great
Excel allows you to save the file as a .csv file instead of .xls. If you can use this, you could use the CSVReader from Unify in order to import your data.
If you want to keep the .xls, you could try Unity Quick-sheet, I didn't try it myself.
Once the data are loaded, you can store them in a simple structure and build a List or a Dict out of it, depending on the requirement.
I have never used Vuforia so I won't be able to help you there.
Related
For a little windows application, I need to display a specific range of a worksheet into a container of my WPF window. This range contains shapes and also notes that have to de displayed too.
This app takes a folder of many excel files with the same format. After choosing the folder, the user selects the file and the part of the file (Part One, Part two ...) The parts don't correspond to rows or columns, it is like "D28:AA39". The selection works well, selection of range too but once my Range is selected I don't know how to display it. Datagrid doesn't seem to display shapes and notes.
The app is supposed to be used on a small screen and with a device with not awesome specs so displaying in a new Excel file isn't a viable solution. The final result is to display the range in my C# window with all the data. Those data doesn't need to be alterable, they just need to be readable. Thanks a lot for helping me.
So I figured out myself how to do it the "simplest" way.
To make this opration i just used the [Range].CopyPicture() which allow you to copy the range as a picture in the clipboard.
Then you save this into as a temporary file and once it is done you just have to display an Image in a container.
Hope it will help other people.
What I'm really trying to achieve
We have an Excel dashboard which is built to be used in tandem with an Export from our in-house application. The generation of the data Excel file is done with EPPlus and we were convinced that we could use the Excel Dashboard as the "base" file for the generation, so that the exported file contained the dashboard in one worksheet and the dataset in another worksheet.
So the user would receive everything they needed in one single file.
We sort of got going with this thanks to named ranges which dynamically adapt to the size of the dataset, covered here
However, we've found, that since the DataModel in the Excel dashboard file is an OLAP Cube, we can't update the underlying dataset and save it with EPPlus and receive an error about "the cache source is not a worksheet" when trying to save the sheet.
So while we worked on that, we sought out a temporary solution... where we've also hit a snag.
The new problem
The temporary solution we thought of is to distribute the Excel dashboard and the data as two separate Excel files. The Dashboard is distributed to those who need it and the data exports can then be generated from our application.
We thought that the only downside of this would be that it would require the user to rename and place the data file side by side with the Excel Dashboard manually.
However, we are running into an issue where Excel is insisting on using the absolute path to the data file instead of a relative path.
This results in requiring the user to point the source to the data export manually. Which is, apparently, done this way:
Now, I'm showing the entire process to also give some insight into the way we've set it up, since I'm not sure I'm using the right words about the technical details - and perhaps I'm grossly mistaken in the approach.
Overall, the way it works
File A contains the dashboard, some sheets with pivot tables used by the dashboard. The pivot tables are all working off of the aforementioned Data Model in the sheet which is a Cube (we need it to be a cube for some of the functions we use in the pivot tables). The Data Model is based on a named range including all the data in one of the worksheets.
File B is the one generated by our application. The two files were placed side by side when designing the dashboard and mapping the data since I was of the impression that Excel attempted to keep relative file paths when possible. The file consists of a single worksheet containing the exported data.
At this point, the challenge was to automatically pull in data from File B into the worksheet in File A. I did this by going to the Data tab and using the Get Data function to point it to File B and telling Excel to load the data from the specified sheet.
This worked like a charm although the "solution" seems overly complicated.
All was well until we tried to use sheet from another machine/directory. Then we found that the path to File B seemed to be absolute and that the data file could no longer be found.
So, the short question after this long-winded explanation is: "How can I possibly have Excel use a relative path to another file, when importing data from an external file with the "Get Data" function?"
By getting more familiar with Power Query I've been able to come up with a solution to this.
My setup is still as described above.
First, I have a sheet with some "system" values I use various places in the Workbook. I added a field there with the following Excel formula:
=LEFT(CELL("filename");FIND("[";CELL("filename");1)-1)
This provides me with the absolute path to the folder where my File A resides.
I use this value, and concatenate the expected filename of File B which holds the data. The result is an absolute path, pointing to where I expect the data file to be located.
I then added a name range pointing to the exact cell where this value is contained.
Next, I added a new Power Query function like this:
= (rangeName) => Excel.CurrentWorkbook(){[Name=rangeName]}[Content]{0}[Column1]
The function takes the name of a named range as a parameter and spits back the value. I my case I called the function GetValue. This function can now be used in other Power Query scripts.
Finally, I loaded up the Power Query scripts which is responsible for loading the data from the other Excel sheet. In that script, I changed the path of the file to this:
Source = Excel.Workbook(File.Contents(GetValue("FilePath")), null, true),
The single thing to notice here is the call of GetValue("FilePath") for the path parameter of File.Contents. FilePath is the name I gave the range pointing to the cell. All it does, is load the path from my sheet and use that as the path for the Excel sheet holding the data.
A quite convoluted solution, but it works.
I'm making a game in Unity C# and need to extract voxel position (and ideally color) from my MagicaVoxel editor which saves it's files in the .vox format, and can export in a few other ones.
I'd think it's best to extract this information from the .vox files, but none of my text editing programs could decern it's encoding.
Does anyone know how exactly I should go about getting this data?
Here's the answer in case someone is still interested: with the export option you can save it in the .ply format (click 'point' - export point clouds). If you open the .ply file with a text editor, you will find the coordinates and the associated RGB values.
I am working on converting large data collection text files to excel. I have been able to successfully read-in and manipulate a text file, but am having difficulty on exporting it to excel.
I currently have data like coordinates in separate lists (x coordinate in a list, y coordinates in another list), I want it so that when the data is viewed in excel that the x and y coordinates are displayed in separate columns. I have looked online and saw a lot of people recommend DataGridView, but I am not familiar with it, and after reading the documentation, still don't understand it. I was wondering what the best approach is to convert these lists into columns in an excel file. Thanks for your suggestions!
Assuming you have some data in list objects, you should be able to create Excel files as described in Create Excel (.XLS and .XLSX) file from C#.
I am calling a web service and the data from the web service is in csv format.
If I try to save data in xls/xlsx, then I get multiple sheets in a workbook.
So, how can I save the data in csv with multipletab/sheets in c#.
I know csv with multiple tabs is not practical, but is there any damn way or any library to save data in csv with multiple tabs/sheet?
CSV, as a file format, assumes one "table" of data; in Excel terms that's one sheet of a workbook. While it's just plain text, and you can interpret it any way you want, the "standard" CSV format does not support what your supervisor is thinking.
You can fudge what you want a couple of ways:
Use a different file for each sheet, with related but distinct names, like "Book1_Sheet1", "Book1_Sheet2" etc. You can then find groups of related files by the text before the first underscore. This is the easiest to implement, but requires users to schlep around multiple files per logical "workbook", and if one gets lost in the shuffle you've lost that data.
Do the above, and also "zip" the files into a single archive you can move around. You keep the pure CSV advantage of the above option, plus the convenience of having one file to move instead of several, but the downside of having to zip/unzip the archive to get to the actual files. To ease the pain, if you're in .NET 4.5 you have access to a built-in ZipFile implementation, and if you are not you can use the open-source DotNetZip or SharpZipLib, any of which will allow you to programmatically create and consume standard Windows ZIP files. You can also use the nearly universal .tar.gz (aka .tgz) combination, but your users will need either your program or a third-party compression tool like 7Zip or WinRAR to create the archive from a set of exported CSVs.
Implement a quasi-CSV format where a blank line (containing only a newline) acts as a "tab separator", and your parser would expect a new line of column headers followed by data rows in the new configuration. This variant of standard CSV may not readable by other consumers of CSVs as it doesn't adhere to the expected file format, and as such I would recommend you don't use the ".csv" extension as it will confuse and frustrate users expecting to be able to open it in other applications like spreadsheets.
If I try to save data in xls/xlsx, then I get multiple sheets in a workbook.
Your answer is in your question, don't use text/csv (which most certainly can not do multiple sheets, it can't even do one sheet; there's no such thing as a sheet in text/csv though there is in how some applications like Excel or Calc choose to import it into a format that does have sheets) but save it as xls, xlsx, ods or another format that does have sheets.
Both XLSX and ODS are much more complicated than text/csv, but are each probably the most straightforward of their respective sets of formats.
I've been using this library for a while now,
https://github.com/SheetJS/js-xlsx
in my projects to import data and structure from formats like: xls(x), csv and xml but you can for sure save in that formats as well (all from client)!
Hope that can help you,, take a look on online demo,
http://oss.sheetjs.com/js-xlsx/
peek in source code or file an issue on GH? but I think you will have to do most coding on youre own
I think you want to reduce the size of your excel file. If yes then you can do it by saving it as xlsb i.e., Excel Binary Workbook format. Further, you can reduce your file size by deleting all the blank cells.