我一直在尝试以下C#代码从doc文件中提取图像,但它不起作用:
object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document oDoc = new Microsoft.Office.Interop.Word.Document();
oWord.Visible = false;
object str1 = "C:\\doc.doc";
oDoc = oWord.Documents.Open(ref str1, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
if (oDoc.InlineShapes.Count > 0) {
for (int j = 0; j < oDoc.InlineShapes.Count; j++)
{
oWord.ActiveDocument.Select();
oDoc.ActiveWindow.Selection.CopyAsPicture();
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(typeof(System.Drawing.Bitmap)))
{ …Run Code Online (Sandbox Code Playgroud) 在VB 6.0中,有人制作了程序.在那个节目中,他使用了
If tmpVar <> "" Then
Run Code Online (Sandbox Code Playgroud)
是啊它在6.0中运作良好.
If tmpVar has string, 有用.
If tmpVar has double,它也有效.
我认为在vb 6.0中,""意味着像null一样.所以无论tmpVar有anyValue,它都有效.但是当我把这个程序转换成.Net时.它不再起作用了
因为在.Net中,""无法与双重比较.我认为在.Net ""中只是字符串不像vb 6.0那样的null
所以我用Nothing而不是"".但它也有问题.
例如,当我使用它时
If tmpVar <> Nothing Then
Run Code Online (Sandbox Code Playgroud)
看起来没问题.但是,如果tmpVar有数字0,它不起作用,因为他们思考Nothing并且0是相同的.我不希望这样.因为0并没有什么不同.但他们认为他们是一样的.
所以我又改变了我的程序
If tmpVar IsNot Nothing Then
Run Code Online (Sandbox Code Playgroud)
是啊.看起来好像没问题了.但如果tmpVar有"",则不起作用.
总而言之,在vb 6.0中,这""意味着像null一样空.它可以与任何类型进行比较.
但转换后,在vb.net中,这""并不意味着像null一样空.它只是字符串.它无法与doubletype相比.即使我改""到Nothing,它不是一样用VB 6.0 "".我给你上面的例子.所以,如果有人知道这个解决方案,请告诉我.这让我很疯狂.
我有一个mdi父级form,我forms在运行时以mdi子格式打开我的另一个代码:
private void MenuItem_Click(object sender, EventArgs e)
{
childform = new childform ();
frm.MdiParent = Mdiparent;
frm.WindowState = FormWindowState.Maximized;
frm.Show();
}
Run Code Online (Sandbox Code Playgroud)
但问题是:当当前表单打开时,用户可以打开另一个表单,并且可以重复多次,以便打开每个表单,以便在用户打开新的子表单之前关闭当前子表单的代码?
我正在将我的Web应用程序从zf1移动到zf2以及我对sql查询的问题,我无法弄清楚如何建立联合.
我曾经能够做到
$select->union($select1, $select2, $select3)
Run Code Online (Sandbox Code Playgroud)
但Zend\Db\Sql\Select不再有union()方法了.
还有办法在zf2的查询中建立联合吗?
基本上我需要对字符串列表进行排序,但字符串中有小写,大写和数字.目前,当它对它们进行排序时,它的值a和A相同的字母如下:
acfgh
aztyu
Ahtwm
Run Code Online (Sandbox Code Playgroud)
将分类为:
acfgh
Ahtwm
aztyu
Run Code Online (Sandbox Code Playgroud)
但是我希望它能在小写字母(以及大写字母之前的数字)之前对资本进行排名,这样我才能得到:
Ahtwm
acfgh
aztyu
Run Code Online (Sandbox Code Playgroud)
我宁愿仍然使用库中已包含的方法而不是创建自己的快速排序.
当我单击一个选项卡时,它会显示该选项卡页面的内容,但我想在选择该选项卡时执行一个操作,例如,当我单击“财务选项卡”时,“财务”选项卡中会有一个组合框,组合框应该填充来自sql server的数据,这可能吗?
这是我的SaveAs方法代码:
m_FilePath="D:\Build\abc.xlsx"
m_objOpt=System.Reflection.Missing.Value;
m_objBook.SaveAs(m_FilePath, m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, XlSaveAsAccessMode.xlShared,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
Run Code Online (Sandbox Code Playgroud)
现在我的问题不是如何禁用兼容性检查器,这已经被多次回答了。我的问题是为什么兼容性检查器会出现。excel怎么知道文件有excel 2003的痕迹。D:\Build是空的。
我有这个Combobox充满了对象并且在从 中选择某个对象后,combobox我想在 a 中显示文本Textbox,但由于某种原因,我无法通过我的选择。
这是我的combobox:
private void showBirds()
{
cboBirds.Items.Clear();
foreach (Bird b in Bird.ReadBirdCSV(txtFile.Text))
{
cboBirds.Items.Add(b);
}
}
Run Code Online (Sandbox Code Playgroud)
它基本上显示了 Objects Bird 中鸟类的名称。
private void cboBirds_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//WHAT DO I WRITE HERE TO GET txbGender TO SHOW THE GENDER?
foreach (Bird b in cboBirds.Items)
{
Console.WriteLine(b.Gender +" - " + b.Name +" - " + b.Risk + " - " +b.Reference);
}
//^This shows all info on every bird. …Run Code Online (Sandbox Code Playgroud) 我有一个datagridviewWindows 窗体,其中包含一些列。我想通过后面的代码隐藏 Ist 列( CompanyID )。
但I列并没有隐藏。
尝试过以下两件事:
dgvVendorDetails.Columns["CompanyID"].Visible = false;
Run Code Online (Sandbox Code Playgroud)
和:
dgvVendorDetails.Columns[0].Visible = false;
Run Code Online (Sandbox Code Playgroud)
我不知道这背后的原因。我进行了很多搜索但没有找到解决方案。
我希望我的一些方法可以Object将其转换为可用类型:
*简单的例子
public void PostAction (object act){
object Action = (act.GetType) act;
string ActionName = Action.PostName;
}
Run Code Online (Sandbox Code Playgroud)
通过稍微浏览一下互联网和Stackoverflow,我发现只有在没有类型的情况下调用对象方法的方法
public void PostAction (object act){
Type t = act.GetType(); // myObject.GetType() would also work
MethodInfo GetPostName = t.GetMethod("GetPostName");
GetPostName.Invoke(act, null);
}
Run Code Online (Sandbox Code Playgroud)
有没有更好的办法?我可以将一个对象转换为它的类型??
我正在使用 open xml sdk 创建 excel 文件。我想使用 open xml 阅读它。当我想阅读它时,我在这一行出错
SharedStringTablePart sstpart = workbookPart.GetPartsOfType<SharedStringTablePart>().First();it return null
如果我打开excel文件并再次保存。它会创建共享字符串表并运行。
从excel读取
#region OpenFile
public void OpenFile(string directory)
{
try
{
fs = new FileStream(directory, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
doc = SpreadsheetDocument.Open(fs, false);
}
catch (FileNotFoundException ex)
{
string exception = string.Format("Doya bulunamad?{0}", directory);
throw new ApplicationException(exception);
}
}
#endregion
#region GetWorkSheet
public void AssignWorkSheet(int sheetID)
{
if (fs == null || doc == null)
throw new ApplicationException("Dosya aç?lamad?");
WorkbookPart workbookPart = doc.WorkbookPart;
SharedStringTablePart sstpart …Run Code Online (Sandbox Code Playgroud) 我想创建一个函数或子函数,当它获得焦点时清除文本框.例如:
textbox1包含:"你的名字在这里."
当用户点击它时 在"您在这里的名字." 会消失的.我通过把它做textbox1.clear在GotFocus的事件textbox.
现在我打算在其中添加更多代码.但事情是编码会重复而且很长,因为我打算在许多文本框中执行此操作.我想最小化编码,所以我想创建一个在聚焦时清除文本框的函数,这样我就可以在GotFocus事件中调用函数并以某种方式减少编码.
我现在还不知道怎么做,所以如果有人那么我真的很感谢你给我的建议.
我正在使用visual studio 2010,并创建一个Windows窗体应用程序项目.
我有以下代码,它没有将值保存到单元格和文件中。它显示了cell.cellvalue字段中的价值,但它没有将其写入excel。我不知道如何保存文件。我使用OpenXml-SDK并将datatable值写入每个cell/row创建的电子表格文档。
using (SpreadsheetDocument ssd=SpreadsheetDocument.Open(Server.MapPath(@"\ExcelPackageTemplate.xlsx"),true))
{
WorkbookPart wbPart = ssd.WorkbookPart;
WorksheetPart worksheetPart = wbPart.WorksheetParts.First();
SheetData sheetdata = worksheetPart.Worksheet.GetFirstChild<SheetData>();
string[] headerColumns = new string[] { dt.Columns[0].ColumnName, dt.Columns[1].ColumnName,dt.Columns[2].ColumnName };
DocumentFormat.OpenXml.Spreadsheet.Row r = new DocumentFormat.OpenXml.Spreadsheet.Row();
int RowIndexer = 1;
//int colInd=0;
r.RowIndex = (UInt32)RowIndexer;
string test = ColumnName(RowIndexer);
foreach (DataColumn dc in dt.Columns)
{
DocumentFormat.OpenXml.Spreadsheet.Cell cell = new DocumentFormat.OpenXml.Spreadsheet.Cell();
cell.CellReference = test+RowIndexer;
cell.DataType = CellValues.InlineString;
cell.InlineString = new InlineString(new Text(dc.ColumnName.ToString()));
DocumentFormat.OpenXml.Spreadsheet.CellValue value = new DocumentFormat.OpenXml.Spreadsheet.CellValue();
r.AppendChild(cell); …Run Code Online (Sandbox Code Playgroud)