I can barely find stuff for npoi when I do its for poi and its lacking.
I found this for poi:
CTP ctP = p.getCTP();
CTSimpleField toc = ctP.addNewFldSimple();
toc.setInstr("TOC \\h");
toc.setDirty(STOnOff.TRUE);enter code here`enter code here`
And was able to "adapt" into this
XWPFParagraph p=doc.CreateParagraph();
CT_P ctP = p.GetCTP();
CT_SimpleField toc = ctP.***Field not working***;
toc.instr="TOC \\h";
toc.dirty=ST_OnOff.True;
(When I wrote Field not working, its 'cause i can't find the c# variation)
Also found
XWPFDocument doc = new XWPFDocument();
doc.CreateTOC();
But can't find how to set it up.
Might be simple but I'm still trying to learn and can't find proper documentation.(Also if you can help me add pagination would be awesome)
Thanks in advance :)
private static XWPFTable createXTable(XWPFDocument myDoc, DataTable dtSource)
{
int rowCount = dtSource.Rows.Count;
int columnCount = dtSource.Columns.Count;
CT_Tbl table = new CT_Tbl();
XWPFTable xTable = new XWPFTable(table, myDoc, rowCount, columnCount);
xTable.Width = 5000;
for (int i = 0; i < rowCount; i++)
{
for (int j = 0; j < columnCount; j++)
{
xTable.GetRow(i).GetCell(j).SetParagraph(SetCellText(xTable, dtSource.Rows[i][j].ToString()));
}
}
return xTable;
}
Related
I'm trying to recreate the following sample https://github.com/dotnet/machinelearning/blob/master/docs/samples/Microsoft.ML.Samples/Dynamic/SsaSpikeDetectorTransform.cs
but I keep getting an error that DataOperations doesn't contain a definition for the ReadFromEnumerable method.
I also get an error that the CreateEnumerable method doesn't exist, but I suspect it relates to the ReadFromEnumerable error.
I've copied the entire namespaces and code in case I might have missed out something, but the error still occurs.
Read From Enumerable method
var ml = new MLContext();
//Generate sample series data with a recurring pattern and a spike within the pattern
const int SeasonalitySize = 5;
const int TrainingSeasons = 3;
const int TrainingSize = SeasonalitySize * TrainingSeasons;
var data = new List<SsaSpikeData>();
for (int i = 0; i < TrainingSeasons; i++)
for (int j = 0; j < SeasonalitySize; j++)
data.Add(new SsaSpikeData(j));
//This is a spike
data.Add(new SsaSpikeData(100));
for (int i = 0; i < SeasonalitySize; i++)
data.Add(new SsaSpikeData(i));
// Convert data to IDataView.
var dataView = ml.Data.ReadFromEnumerable(data); //This is where the error occurs
CreateEnumerable Method
var predictionColumn = ml.CreateEnumerable<SsaSpikePrediction>(transformedData, reuseRowObject: false);
Just like dlatikay said, it was a version mismatch.
The sample I provided is from a version that's still in preview.
For ML.NET 0.9.0 and older versions, you need to use CreateStreamingDataView.
To get ReadFromEnumerable and CreateEnumerable working, you can download the ML.NET 0.10.0 and 0.11.0 preview packages from here https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.ML/0.11.0-preview-27404-5
I have a 3D double array double[,,] surfaceData = new double[5, 304, 304]; that I then populate with nested for loops. It works great in C#, but how do I convert it to a .mat Matlab-readable file?
I am using csmatio. I can output .mat files with it:
List<MLArray> mlList = new List<MLArray>();
mlList.Add(mlDouble);
MatFileWriter mfw = new MatFileWriter("SurfaceDataTest.mat", mlList, false);
...where mlDouble is an MLDouble object in csmatio. This is no issue. The issue is populating that mlDouble when I can't directly reference three indeces (mlDouble[4,3,60] for example). Instead, the usage guidlines suggest I populate my 3D array like so...
I have tried many nested for loops and haven't yet found a solution.
Here is a messy example:
for(int i = 0; i < 304; i++)
{
for(int j = 0; j < 304; j++)
{
for(int k = 0; k < 5; k++)
{
mlDouble.Set(surfaceData[k, j, i], i, j * k);
}
}
}
In case this helps anyone, I found it easier to use MatFileHandler instead of csmatio.
In MatFileHandler, simply define a DataBuilder:
DataBuilder builder = new DataBuilder();
Define a MatLab variable with a string name and the C# object:
var matVar = builder.NewVariable("<VariableNameForML>", csharpvar);
Create a list of variables you want to add, even if only adding one:
List<IVariable> matList = new List<IVariable>();
matList.Add(matVar);
Then:
var matFile = builder.NewFile(matList);
using (var fileStream = new FileStream("SurfaceData.mat", FileMode.Create))
{
var writer = new MatFileWriter(fileStream);
writer.Write(matFile);
}
Hope this helped anyone in the same position as me :)
I am new in Selenium Webdriver. I want to get all Value from a html Table with 2 column and add them in a Hashtable. I don't know where to begin.
Any help would be appreciated.
Try this:
var hashTable = new Hashtable();
var table = Driver.FindElement(By.Id("table"));
int rowCount = table.FindElements(By.TagName("tr")).Count;
for (int i = 0; i < rowCount; i++)
{
hashTable.Add($"row{i}", table.FindElements(By.TagName("tr"))[i].Text);
}
I'm writing a windows form application which must exchange the content of Word bookmarks between two documents.
There are two similar documents (wordDocument and wordPattern) with similar amount of bookmarks. I'm trying this:
for (int i = 1; i <= wordDocument.Bookmarks.Count; i++)
{
object j = i;
wordDocument.Bookmarks.get_Item(ref j).Range.Text = wordPattern.Bookmarks.get_Item(ref j).Range.Text.ToString();
//MessageBox.Show(wordDocument.Bookmarks[i].Range.Text);
//MessageBox.Show(wordPattern.Bookmarks[i].Range.Text);
}
But it does the task incorrectly. I mean, it does it in improper order and deletes bookmarks. Help me by providing right way to exchange the text inside the bookmarks.
int count1 = 0;
int count2 = 0;
foreach (Word.Bookmark bookmark1 in wordDocument.Bookmarks)
{
Word.Range bmRange = bookmark1.Range;
//bmRange.Text = "заметка" + count1;
listOfRanges.Add(bmRange);
count1++;
}
foreach (Word.Bookmark bookmark2 in wordPattern.Bookmarks)
{
Word.Range mbRange = bookmark2.Range;
mbRange.Text = listOfRanges[count2].Text;
count2++;
}
Solved it that way.
hello i have the following code which lets me display the emails in my inbox on a list view control and display the corrospoding body in a rtb my question is there a better way to handle this data and display it than the way below im pretty new to c# so detailed answers would be great
p.s im using the chilkat imap component to handle the server side if things
Thanks In Advance
Chilkat.MessageSet msgSet = imap.Search("ALL", true);
bundle = imap.FetchBundle(msgSet);
Chilkat.Email email;
int i;
for (i = 0; i < bundle.MessageCount - 0; i++)
{
email = bundle.GetEmail(i);
System.Windows.Forms.ListViewItem itmp = new System.Windows.Forms.ListViewItem(email.From);
System.Windows.Forms.ListViewItem.ListViewSubItem itms1 = new System.Windows.Forms.ListViewItem.ListViewSubItem(itmp, email.Subject);
System.Windows.Forms.ListViewItem.ListViewSubItem itms2 = new System.Windows.Forms.ListViewItem.ListViewSubItem(itmp, email.FromName);
itmp.SubItems.Add(itms1);
itmp.SubItems.Add(itms2);
listView1.Items.Add(itmp).Tag = i;
richTextBox1.Text = email.Body;
}
// Save the email to an XML file
bundle.SaveXml("email.xml");
Updated Code
Chilkat.MessageSet msgSet = imap.Search("ALL", true);
bundle = imap.FetchBundle(msgSet);
Chilkat.Email email;
int i;
for (i = 0; i < bundle.MessageCount; i++)
{
email = bundle.GetEmail(i);
string[] row = new string[]{email.From,
email.Subject,email.FromName};
object[] rows = new object[] { row };
foreach (string[] rowArray in rows)
{
listView1.Rows.Add(rowArray);
}
I think , you are doing correct only small point
Put a null check for bundle and email object.
for (i = 0; i < bundle.MessageCount - 0; i++) m, why are you substracting 0 from bundle.MessageCount
your code is simple and its doing what it is intended to do so why change at this time.