小编Cin*_*ter的帖子

使用 Java 将 JSON 转换为 XML

我正在尝试将 JSON 转换为 XML。但我收到一个错误,即 org.json 无法解析。我还导入了外部 jar 文件 java-json.jar。下面是我的java代码:

import org.json.JSONObject;
public class JsontoXML{
  public static void main(String args[])
  {
    String str ={'name':'JSON','integer':1,'double':2.0,'boolean':true,'nested' {'id':42},'array':[1,2,3]}"; 
    JSONObject json = new JSONObject(str);
    String xml = XML.toString(json);
    System.out.println(xml);

  }
Run Code Online (Sandbox Code Playgroud)

}

java xml json

4
推荐指数
1
解决办法
2万
查看次数

VBA:如何测试字符串是否为空

我在VBA中还很陌生,我还没有完全习惯语法,所以对我的问题听起来很愚蠢感到抱歉。

我正在Word 2010中使用RequisitePro40和VBA 7.0。在我的一个模块中,我具有以下循环和If条件:

Dim rqRequirements As ReqPro40.Requirements
Dim rqRequirement As ReqPro40.Requirement
Const eAttrValueLookup_Label = 4
Dim a As Integer
...

For Each vReqKey In rqRequirements
    Set rqRequirement = rqRequirements(vReqKey)

    If rqRequirement.AttrValue("MyAttreName", eAttrValueLookup_Label).text <> Null Then
        a = 1
    End If

    If rqRequirement.AttrValue("MyAttreName", eAttrValueLookup_Label).text = Null Then
         a = 2
    End If

 Next
Run Code Online (Sandbox Code Playgroud)

在循环的每次迭代中,将同时执行a = 1a = 2

基于,相等和不相等运算符为“ =”和“ <>”。因此,我希望为字符串执行a = 1a = 2。我的语法有问题吗?还是ReqPro相关问题?

我也尝试使用“ Is”和“ IsNot”运算符,但它们导致编译器错误:类型不匹配

有人可以帮我弄这个吗?

更新: …

vba requirements word-vba

4
推荐指数
1
解决办法
9024
查看次数

我如何使用 OpenXML C# 水平合并 Microsoft Word 表格单元格

我有一张 Microsoft Word 表格。我需要在表格的一行中合并两个单元格。我得到了我需要的细胞:

Wordprocessing.TableRow row = table.Elements<Wordprocessing.TableRow>().ElementAt(i);

 Wordprocessing.TableCell cell1 = row.Elements<Wordprocessing.TableCell>().ElementAt(j);

 Wordprocessing.TableCell cell2 = row.Elements<Wordprocessing.TableCell>().ElementAt(j+1);
Run Code Online (Sandbox Code Playgroud)

如何水平合并这些单元格?

c# merge ms-word cell openxml

4
推荐指数
1
解决办法
3833
查看次数

使用标题名称自动过滤字段

我尝试使用自动筛选功能,但使用标题名称“ID”而不是列数的字段。我尽了最大努力,但收到此错误消息“高级过滤器在迭代时失败,运行时错误 1004”

我被它困住了两天。谢谢你的帮助

代码 :

Sub AdataPreparation()
Dim WorkBk As Workbook, WorkSh As Worksheet, WrkTab As range, FilterRow As Variant
Set WorkBk = Workbooks.Open(Filename:="C:\Users\Documents\DataApplied.xlsm")
Set WorkSh = Sheets("sheet2") 
WorkSh.Activate 
Set WrkTab = range("A1").CurrentRegion 
WrkTab = ActiveRange
FilterRow = Application.Match("ID", WrkTab, 0)
Selection.AutoFilter Field:=FilterRow, Criteria1:="="
End Sub
Run Code Online (Sandbox Code Playgroud)

excel vba

4
推荐指数
1
解决办法
2万
查看次数

ng-pick-date picker:如何设置日期格式?

我想使用选择日期选择器。我想设置日期格式,但不知道该怎么做。那么谁能给我一个例子,说明如何设置日期格式?

这是我的日期选择器的代码:

<label class="control-label my-label">From Date</label>
<div class="input-group">
  <input tabindex="1" class="form-control" [owlDateTime]="fromDateOfConfirmation" [(ngModel)]="fromDate" name="fromDate" [owlDateTimeTrigger]="fromDateOfConfirmation"
   >
  <span class="input-group-addon trigger" [owlDateTimeTrigger]="fromDateOfConfirmation">
    <span class="fa fa-calendar nopad2 fa-lg"></span>
  </span>
  <owl-date-time [pickerType]="'calendar'" #fromDateOfConfirmation></owl-date-time>
</div>
Run Code Online (Sandbox Code Playgroud)

编辑

我已经尝试过了。

export const MY_NATIVE_FORMATS = {
  parseInput: 'LL LT',
  fullPickerInput: 'LL LT',
  datePickerInput: 'LL',
  timePickerInput: 'LT',
  monthYearLabel: 'MMM YYYY',
  dateA11yLabel: 'LL',
  monthYearA11yLabel: 'MMMM YYYY',
};
providers: [
{ provide: OWL_DATE_TIME_FORMATS, useValue: MY_NATIVE_FORMATS },
],
Run Code Online (Sandbox Code Playgroud)

datepicker date-format angular

4
推荐指数
2
解决办法
3526
查看次数

Word.ApplicationClass.Activedocument 突然出现异常

我在 Word VSTO 加载项项目中有这样一行代码,它曾经可以工作,但突然不再工作了:

Microsoft.Office.Interop.Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;
Run Code Online (Sandbox Code Playgroud)

在它按预期返回Document对象之前,我可以毫无问题地读取和操作它。但现在它抛出System.Runtime.InteropServices.COMException异常。“Word遇到了问题。” 很有帮助。该异常包含 0x800A13E9 的 HRESULT,到目前为止这也没有帮助我。内存不足还是怎么的?我不知道。

新行为似乎是在除夕夜左右开始的(不确定,因为过去几周我没有使用该加载项),并且它是在安装加载项时开始的,即代码中没有任何更改,重新编译或重新安装以使其发生。此后我重建了该项目,认为证书可能已过期或其他原因,但错误仍然发生。

也许值得注意的是,我仍然可以访问应用程序实例的其他属性。例如,这一行不会抛出异常:

int numDocuments = Globals.ThisAddIn.Application.Documents.Count;
Run Code Online (Sandbox Code Playgroud)

但是当我使用 迭代集合时Documentsforeach它只是跳过循环,就好像计数为零一样。

我唯一能想到的是 Office (365) 的更新破坏了与 VSTO 相关的某些内容。但我从哪里开始调试呢?


好的,所以我尝试创建一个新的 Word VSTO 加载项,不更改任何默认项目属性,而是添加带有单个按钮的单个功能区和以下方法:

private void button1_Click(object sender, RibbonControlEventArgs e)
{
    try
    {
        var x = Globals.ThisAddIn.Application.ActiveDocument;
    }
    catch  (Exception ex)
    {
        ;
    }
}
Run Code Online (Sandbox Code Playgroud)

它在获取 ActiveDocument 属性时抛出完全相同的异常。不过,我确实注意到,加载加载项时还会抛出两个异常,加载原始加载项时也会抛出这些异常(以前工作正常):

Exception thrown: 'System.Deployment.Application.DeploymentException' in System.Deployment.dll
Exception thrown: 'System.Security.Cryptography.CryptographicException' in Microsoft.VisualStudio.Tools.Applications.Hosting.dll
Run Code Online (Sandbox Code Playgroud)

它们不会阻止加载项加载和运行,但也许它们与问题有关?不知道去年问题出现之前是否也被抛出过。

不过,我确实有几个 Excel 加载项,它们仍然可以在相同版本的 VSTO、Visual …

c# vsto ms-word comexception office365

4
推荐指数
1
解决办法
2979
查看次数

haskell [[Char]] to [[Int]]

I've got problem with a Haskell program. I'm trying to change [[Char]] to [[Int]] I've got

["2","2","1","2,2","1"] 
Run Code Online (Sandbox Code Playgroud)

list of char list and I'm trying to change it to [[Int]]

[[2],[2],[1],[2,2],[1]]
Run Code Online (Sandbox Code Playgroud)

I've tried

f :: [String] -> [Int]
f = map read
Run Code Online (Sandbox Code Playgroud)

but it gives me

[2,2,1,*** Exception: Prelude.read: no parse

Can anybody help me with this?

int haskell list char

4
推荐指数
1
解决办法
98
查看次数

如何在 dart post 请求中发送数组

我尝试使用其registration_ids.

这是我的代码:

List<String> tokens=["token1","token2"];
final  url='https://fcm.googleapis.com/fcm/send';
 http.post(url,headers:{
  "Accept": "application/json",
  "Authorization":"key=mykey"
  ,"project_id":"proID"
},
body: 
  {
 "registration_ids" :tokens ,
 "collapse_key" : "type_a",
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification"
 }
}
Run Code Online (Sandbox Code Playgroud)

当应用程序运行时,显示此错误:

发生异常。_CastError(类型“List”不是类型转换中类型“String”的子类型)

如何修复它?

android dart flutter firebase-cloud-messaging

4
推荐指数
1
解决办法
1万
查看次数

如何获取文档中所有内容控件的列表?

我正在使用互操作,我想得到word文档中包含的所有内容控件的列表(在正文,形状,页眉,页脚..).这是正确的,也是最好的方法:

public static List<ContentControl> GetAllContentControls(Document wordDocument)
{
  if (null == wordDocument)
    throw new ArgumentNullException("wordDocument");

  List<ContentControl> ccList = new List<ContentControl>(); ;
  // Body cc
  var inBodyCc = (from r in wordDocument.ContentControls.Cast<ContentControl>()
          select r);
  ccList.AddRange(inBodyCc);

  // cc within shapes
  foreach (Shape shape in wordDocument.Shapes)
  {
    if (shape.Type == Microsoft.Office.Core.MsoShapeType.msoTextBox)
    {
      ccList.AddRange(WordDocumentHelper.GetContentControlsInRange(shape.TextFrame.TextRange));
    }
  }

  // Get the list of cc in the story ranges : wdFirstPageHeaderStory, wdFirstPageFooterStory, wdTextFrameStory (textbox)... 
  foreach (Range range in wordDocument.StoryRanges)
  {
    ccList.AddRange(WordDocumentHelper.GetContentControlsInRange(range));
  }
  return ccList;
}

public static List<ContentControl> …
Run Code Online (Sandbox Code Playgroud)

c# interop ms-word word-contentcontrol

3
推荐指数
2
解决办法
8731
查看次数

Android ObjectAnimator如何识别属性setter方法?

setX如果将属性x指定为字符串,ObjectAnimator如何调用适当的方法?我的意思是,用什么技术来识别我想要为rotation我的视图的属性设置动画并调用该视图的适当方法setRotation

我已经了解了ObjectAnimator如何工作并设法使用它,它非常简单,我只是对操作原理感到好奇.

java android android-animation objectanimator

3
推荐指数
1
解决办法
2601
查看次数