我是VB编码的新手,我正在尝试将多个excel文件工作表保存到csv,我不知道为多个工作表执行此操作,但我找到了一种方法来处理单个文件.我在这个网站上找到了对我正在尝试的内容非常有用的代码,唯一的问题是文件是用工作表名称保存的,但我试图用原始文件和工作表名称保存它们filename_worksheet name,我试图自己这样做,但不断收到错误,你能告诉我我做错了什么吗?
我使用的代码如下:
Public Sub SaveWorksheetsAsCsv()
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
' Store current details for the workbook
SaveToDirectory = "H:\test\"
For Each WS In ThisWorkbook.Worksheets
WS.SaveAs SaveToDirectory & WS.Name, xlCSV
Next
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat
Application.DisplayAlerts = True
' Temporarily turn alerts off to prevent the user being prompted
' about overwriting the original file.
End Sub
Run Code Online (Sandbox Code Playgroud) 我一直在拼命寻找在WPF应用程序中显示HTML的简单方法.有一些选项:
1)使用WPF WebBrowser控件
2)使用Frame Control
3)使用第三方控件
但是,我遇到了以下问题:1)WPF WebBrowser控件不是真正的WPF(它是一个包装在WPF中的Winforms控件).我找到了一种为此创建包装器的方法,并使用DependencyProperties导航到带有绑定和propertychanged的HTML文本.这个问题是,如果你在WPF scrollviewer中放置Winforms控件,它不会尊重z-index,这意味着winform始终位于其他WPF控件之上.这非常烦人,我试图通过创建一个承载ElemenHost等的WindowsFormsHost来解决它.但这显然完全破坏了我的绑定.
2)如果显示HTML内容,则帧控制具有相同的显示问题.不是一种选择.
3)我还没有找到WPF的原生HTML显示.所有选项都是winforms,并且存在上述问题.
我现在唯一的出路就是使用微软的HtmlToXamlConverter,它有时会很难崩溃.(MSDN)
有没有人对如何在WPF中显示HTLM有任何其他建议,没有这些问题?
抱歉这个长期问题,希望有人知道我在说什么......
我在这里遇到一种奇怪的情况.我搞定了,但我不明白为什么.情况如下:
我的应用程序(网站)必须调用WCF服务.WCF服务公开netTcpBinding并需要传输安全性(Windows).客户端和服务器位于同一个域中,但位于不同的服务器上.
因此生成客户端会导致以下配置(主要是默认值)
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="MyTcpEndpoint" ...>
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:xxxxx/xxxx/xxx/1.0"
binding="netTcpBinding" bindingConfiguration="MyTcpEndpoint"
contract="Service.IMyService" name="TcpEndpoint"/>
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
当我运行网站并调用该服务时,我收到以下错误:
System.ServiceModel.Security.SecurityNegotiationException: Either the target name is incorrect or the server has rejected the client credentials. ---> System.Security.Authentication.InvalidCredentialException: Either the target name is incorrect or the server has rejected the client credentials. ---> System.ComponentModel.Win32Exception: The logon attempt failed
--- End of inner exception stack trace …Run Code Online (Sandbox Code Playgroud) 我正试图找到一种方法来查找有关TFS2012中的代码审查请求/响应项的详细信息.
我可以通过以下方式查询所有代码审查请求/响应项:
const string TfsUri = "http://mytfsserver:8080/tfs/Default ProjectCollection";
var tfs = new TfsTeamProjectCollection(new Uri(TfsUri));
var store = tfs.GetService<WorkItemStore>();
var versionStore = tfs.GetService<Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer>();
var queryText = "SELECT [System.Id],
FROM WorkItems
WHERE [System.WorkItemType] = 'Code Review Request'
or [System.WorkItemType] = 'Code Review Response'";
var query = new Query(store, queryText);
var result = query.RunQuery().OfType<WorkItem>();
Run Code Online (Sandbox Code Playgroud)
这给了我一个WorkItem类型列表.当我遍历result.FirstOrDefault().Fields属性时,它确实给了我一些有关ShelveSet的有用信息,它与Code Review相关,即"Associated Context".使用此信息,我可以查询ShelveSet:
var versionStore = tfs.GetService<VersionControlServer>();
var shelveset = versionStore.QueryShelvesets("someCodeReviewId_xxxx","someUserName");
Run Code Online (Sandbox Code Playgroud)
这给了我一个ShelveSet项目,但那就是我被困住的地方.
我查看Microsoft.TeamFoundation.CodeReview了两者Microsoft.TeamFoundation.CodeReview.Components和Microsoft.TeamFoundation.CodeReview.Controls库提供的命名空间,但这对我没有任何帮助.
我的问题是:如何通过TFS API找到代码审查期间ShelveSet上的实际注释(包括一般注释和文件注释)?
好的,这就是问题所在:我写了一个UserControl,它接收一个新的值,比如每100毫秒,并用它做一些事情.它必须处理每个新的值设置器,即使值没有改变.UserControl有几个DependencyProperties:
public double CurrentValue
{
get { return (double)GetValue(CurrentValueProperty); }
set { SetValue(CurrentValueProperty, value); }
}
public static readonly DependencyProperty CurrentValueProperty =
DependencyProperty.Register("CurrentValue", typeof(double), typeof(GraphControl), new UIPropertyMetadata(0d));
Run Code Online (Sandbox Code Playgroud)
在使用此控件的XAML中,我只是将BindingCurrentValue设置为(启用INotifyPropertyChanged)属性:
<uc:UserControl CurrentValue="{Binding MyValue}" ... />
Run Code Online (Sandbox Code Playgroud)
视图模型:
public double MyValue
{
get { return _value; }
set
{
//if (_value == value) return;
_value= value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("MyValue"));
}
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我明确地注释掉了if equals then return它,因此即使值更新为相同的值,它也会触发PropertyChanged事件.
现在回到我的用户控件,我尝试以两种方式注册ValueChanged; 首先使用DependencyPropertyDescriptor:
var propertyDescriptor = DependencyPropertyDescriptor.FromProperty(CurrentValueProperty, typeof(GraphControl));
propertyDescriptor.AddValueChanged(this, OnCurrentValueChanged); …Run Code Online (Sandbox Code Playgroud) 使用由现场TFS2015提供的PowerShell脚本配置构建代理时,脚本会因为无法在服务器上找到代理池而出错.
但是,代理池'default'肯定存在.在另一台服务器上,相同的脚本按预期工作,并且构建运行.请参阅下面的脚本输出.
我试过跟随:
是什么导致脚本在代理池验证时失败?
PS C:\ Windows\system32> E:\ Build\agentConfigureAgent.ps1
输入此代理的名称(默认为Agent-SRV001):BUILD002
输入Team Foundation Server的URL(默认为:http:// [ip-地址]:8080/tfs
为代理池配置此代理?(默认池名称为'default'):
输入此代理的工作文件夹路径(默认为'E:\ Build\agent_work'):E:\ Build \工作
是否要将代理安装为Windows服务(是/否)(默认为Y):n
是否要取消配置任何现有代理(Y/N)(默认为N;代理将更新):
配置代理
解除阻止文件调用代理配置不带/ RunningAsService
调用代理配置不带/ Force
无法找到名称为的代理池:default
警告:配置代理失败,但您可以通过使用/ Force配置来解决此问题.
是否要尝试使用参数-Force(Y/N)再次配置代理:y
呼叫代理配置不带/ RunningAsService
呼叫代理配置/强制
无法 找到名称为agent的代理池:default
E:\ Build\agent\ConfigureAgent.ps1:配置代理失败.在行:1 char:1
+ E:\ Build\agent\ConfigureAgent.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo:NotSpecified:(:) [Write-Error],WriteErrorException
+ FullyQualifiedErrorId:Microsoft.PowerShell.Commands.WriteErrorException,ConfigureAgent.ps1
我正在创建一个新的C#项目.我想将它与MySQL服务器连接.单击"添加引用"时,不显示MySQL.Data.这会导致各种问题,因为我无法将其与我的数据库连接.
我正在使用Visual Studio Ultimate 2010和MySQL 5.5.
请帮忙.
谢谢
我正在使用PowerShell向a发送POST请求REST API.请求的主体如下所示:
{
"title": "game result",
"attachments": [{
"image_url": "http://contoso/",
"title": "good work!"
},
{
"fields": [{
"title": "score",
"value": "100"
},
{
"title": "bonus",
"value": "50"
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
现在,以下PowerShell脚本生成错误的输出:
$fields = @(@{title='score'; value='100'},@{title='bonus'; value='10'})
$fieldsWrap = @{fields=$fields}
#$fieldsWrap | ConvertTo-Json
$attachments = @(@{title='good work!';image_url='http://contoso'},$fieldsWrap)
$body = @{title='game results';attachments=$attachments}
$json = $body | ConvertTo-Json
$json
Run Code Online (Sandbox Code Playgroud)
第3行(如果未注释)产生正确的输出,但是第7行产生:
{
"attachments": [{
"image_url": "http://contoso",
"title": "good work!"
},
{
"fields": "System.Collections.Hashtable System.Collections.Hashtable"
}
],
"title": "game …Run Code Online (Sandbox Code Playgroud) 我正在实现一个显示项目列表的wpf应用程序,并提供通过键入文本框来过滤此列表的功能(我认为这是非常简单的用例).
我们正在使用MVVM结构.
我的问题是,谁负责过滤清单?视图还是视图模型?我应该在xaml.cs中实现"OnTextChanged"事件,还是应该在ViewModel中使用属性并使用PropertyChanged来过滤列表.
后续问题是,我应该在ViewModel中使用BindingList/ObservableCollection,还是使用ICollectionView将ItemsControl绑定到?
我尝试了两种方法,但它们都有效.赋予ViewModel责任使得View从代码中保持空白,但另一方面,我并不完全相信应用过滤是ViewModels的责任(例如:不同的视图可能需要不同的过滤)
有什么想法吗?
谢谢,罗尔
编辑:
把它放在ViewModel中让我困扰的是(在我当前的实现中)有一个System.Windows.Data的引用.这是我在ViewModel中没有的参考,因为它显然与View相关.或者我错过了什么?相关代码:
ICollectionView customerView = CollectionViewSource.GetDefaultView(customers);
Run Code Online (Sandbox Code Playgroud) 考虑以下代码:
<UserControl x:Name=root>
....
<TextBlock Text="Hello World" Margin="{Binding ElementName=root, Path=LeftButtonMargin}"/>
....
</UserControl>
Run Code Online (Sandbox Code Playgroud)
现在,设置FallBackvalue绑定的语法是什么?
我已经尝试了一些不同的选项,但我似乎无法找到正确的语法:
Margin="{Binding ElementName=root, Path=LeftButtonMargin, FallBackValue={}10,10,0,0}"
Margin="{Binding ElementName=root, Path=LeftButtonMargin, FallBackValue={}{10,10,0,0}}"
Margin="{Binding ElementName=root, Path=LeftButtonMargin, FallBackValue={}"10,10,0,0"}"
Run Code Online (Sandbox Code Playgroud)
或者这根本不可能?基本上,我在设计时需要这些值......
wpf ×4
c# ×3
.net ×1
.net-3.5 ×1
api ×1
binding ×1
build-server ×1
callback ×1
csv ×1
database ×1
dns ×1
excel ×1
excel-vba ×1
html ×1
json ×1
mvvm ×1
mysql ×1
object-model ×1
powershell ×1
syntax ×1
tfs ×1
tfs-2015 ×1
tfs2012 ×1
vba ×1
viewmodel ×1
wcf ×1
wcf-client ×1
wcf-security ×1
xaml ×1