小编Ale*_*cha的帖子

C#:Microsoft.Office.Interop.Excel.Range的ID字段不会与Excel表一起保留

在我开始解决问题之前,我想激励它.我的任务是分析Excel工作表中的更改,但不同于通过内置机制记录更改,应该以编程方式检测更改,即使用户已停用更改记录或未安装Excel-AddIn.因此,我使用Microsoft.Interop.Excel-Library来访问工作表和其中的单元格.

现在问题是:为了找到更改,即使用户已经对数据进行了排序或移动,我希望每个单元格都有一个uniqe id,即使被移动或复制也是如此.当然如果复制,表中的id是两次,新添加的单元格没有id,但是没关系.此外,该ID不应该对用户可见,并且用户不应该能够修改或删除它.

所以我查找了一个字段并找到了Range-Object,它可以代表一个单元格,并且具有可以访问的不同成员.一个特殊的领域引起了我的注意,ID领域,看起来像我正在寻找的.

Guid guid = Guid.NewGuid();
((Range) worksheet.Cells[rowNr, columnNr]).ID = guid.ToString();
Run Code Online (Sandbox Code Playgroud)

并且也可以像

Guid guid = Guid.Parse(((Range) worksheet.Cells[rowNr, columnNr]).ID);
Run Code Online (Sandbox Code Playgroud)

这是完美的,因为我能够存储一个字符串(在这种情况下是一个字符串Guid,如123463-fc34-c43a-a391-399fc2)并读取它.当细胞移动时,它也粘在细胞上,移动了

但不幸的是,当文件被保存时,这个ID字段不会被保留,我不知道为什么.我的意思是在关闭并重新打开工作簿之后,所有ID都消失了.

所以我的问题是,如果Range对象中有任何其他成员,那么它可以包含一个字符串(= Guid),并且对用户不可见.我尝试了Name-Member和Comment-Member,但它们都对用户可见,并且可以轻松修改.

或者有没有办法告诉Excel,我还想在保存工作表时保存ID字段?

对于测试,您可以创建项目,添加对Microsoft.Office.Interop.Excel-Dll的引用并添加以下代码(您必须在系统上安装Excel).它是一个单元测试,使用JUnit运行,但只需删除Assert-Command即可在没有JUnit的情况下进行测试:

using System;
using System.IO;
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
public void AddGuidAndRead() 
{
    Excel.Application excelApp = new Excel.Application();
    Workbook excelWorkbook = excelApp.Workbooks.Add(Type.Missing);
    Worksheet worksheet = excelWorkbook.Sheets[1]; //1-based index

    Guid rowGuid1 = Guid.NewGuid();
    const string filename = "C:\\temp\\anyTemporaryFilename.xlsx";

    //Make sure, this file does not exist previously
    if (File.Exists(filename))
        File.Delete(filename);

    //Write the ID …
Run Code Online (Sandbox Code Playgroud)

c# excel range persist

6
推荐指数
1
解决办法
2302
查看次数

如何在GridLayout中为低于21的API使用布局权重

我想使用平均传播8个按钮GridLayout.我想支持的API低于21(这是支持的最小数量layout_columnWeightlayout_rowWeightGridLayout)

这是我的代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="tk.adamnafie.basicphrases.MainActivity"
android:background="@drawable/background">

<GridLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:layout_column="0"
        android:layout_row="0"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:layout_gravity="fill"
        android:id="@+id/button1"
        android:onClick="talk"
        android:text="Good Morning"
        android:layout_width="150dp" />

    <Button
        android:layout_column="1"
        android:layout_row="0"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:layout_gravity="fill"
        android:id="@+id/button2"
        android:onClick="talk"
        android:text="Good Afternoon"
        android:layout_width="150dp" />

    <Button
        android:layout_column="0"
        android:layout_row="1"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:layout_gravity="fill"
        android:id="@+id/button3"
        android:onClick="talk"
        android:text="Good night"
        android:layout_width="150dp" />

    <Button
        android:layout_column="1"
        android:layout_row="1"
        android:layout_columnWeight="1"
        android:layout_rowWeight="1"
        android:layout_gravity="fill"
        android:id="@+id/button4"
        android:onClick="talk"
        android:text="How are you?"
        android:layout_width="150dp" />

    <Button
        android:layout_column="0"
        android:layout_row="2"
        android:layout_columnWeight="1" …
Run Code Online (Sandbox Code Playgroud)

user-interface android android-gridlayout android-support-library

6
推荐指数
1
解决办法
5266
查看次数

Android 4上的传感器融合

似乎在SDK级别15中已经实现了适用于加速度计/陀螺仪/指南针的传感器融合:

链接

在那个线程上他们引用了android源代码:

"框架/基础/服务/传感器服务:重力,方向和旋转矢量虚拟传感器现在基于融合加速度计/陀螺仪/罗盘读数的卡尔曼滤波器"

但我真的找不到文件夹层次结构"frameworks/base/services/sensorservice:"?!!

有人能帮我吗?非常感谢!

编辑:好的我在android框架源代码中自己找到了它,可以在这里浏览:https://android.googlesource.com/platform/frameworks/native/+/master/services/sensorservice/

android sensor

5
推荐指数
0
解决办法
3479
查看次数

如何使用Voice Command在Google Glass上启动应用

我已经在我的Google眼镜上安装了一个应用程序,但是一旦我关闭它,我就必须连接回我的电脑再次启动它.

如何将我的应用程序注册到语音命令列表?例如"Ok Glass,告诉我立方体".因此,在主屏幕上,您以"OK Glass"开头,然后说出用户定义的字符串(例如"向我显示多维数据集"),并且将启动与此字符串关联的应用程序.之前我已经通过在应用程序清单中添加几行来看到了这一点,但无法再找到它.我知道这可能需要一个有根据的Glass设备,但没关系.

这个讨论与这个问题有关,但没有给出答案.

android launcher voice-recognition google-glass

5
推荐指数
1
解决办法
1814
查看次数

在开始编译之前,将Gradle配置为执行自定义生成步骤

我今天开始使用Gradle,在搜索了一个小时并尝试了SO(例如1)和不同博客(例如2)和文档(例如3)的每个可能答案后,我需要一些帮助.

我的问题很简单:如何执行自定义构建步骤(在我的情况下,使用自定义的Android.mk执行ndk-build)作为常规构建过程的一部分?

build.gradle看起来像这样:

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "myApp.prototype"
        minSdkVersion 16
        targetSdkVersion 19

        testApplicationId "myApp.prototype.test"
        testInstrumentationRunner "android.test.InstrumentationTestRunner"
    }

    sourceSets.main.jni.srcDirs = []

    task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
        def rootDir = project.rootDir
        def localProperties = new File(rootDir, "local.properties")
        Properties properties = new Properties()
        localProperties.withInputStream { instr ->
            properties.load(instr)
        }

        def ndkDir = properties.getProperty('ndk.dir')
        println ndkDir

        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            commandLine "$ndkDir\\ndk-build.cmd",
                    'NDK_PROJECT_PATH=build/intermediates/ndk',
                    'NDK_LIBS_OUT=src/main/jniLibs', …
Run Code Online (Sandbox Code Playgroud)

android gradle android-ndk build.gradle android-gradle-plugin

5
推荐指数
1
解决办法
2560
查看次数

永久允许 Xamarin iOS 应用接受传入连接(Xamarin 测试云代理)

我的问题与此问题密切相关,因为我正在创建 Xamarin 应用程序并希望自动测试 UI。我已经按照官方文档中的说明进行操作,但是一旦我完成了最后一步,即添加Xamarin.Calabash.Start();到 AppDelegate.cs 中,我的 Mac 就会不断询问我,它是否允许来自应用程序的传入连接。

防火墙查询以接受我的申请

我可以在应用程序每次启动时和开始测试时手动确认防火墙规则,因为应用程序会一遍又一遍地重新部署。但是 - 如果我不这样做,奇怪的事情就会开始发生:有时它会起作用(我不确定为什么,可能是我之前手动启动了该应用程序),有时我会遇到类似的异常

SetUp : System.Exception : Unable to start CalabashHostStrategyProxy

有什么方法可以永久启用我的应用程序(尤其是测试云代理部分)以接受传入连接?或者至少以某种方式自动摆脱这个对话框?

如果我在 Xamarin 测试云中运行测试,这会影响我的测试执行吗?

macos firewall ui-testing xamarin xamarin-test-cloud

5
推荐指数
1
解决办法
551
查看次数

在Windows 10上禁用TortoiseSVN中的德语拼写检查程序

我在Windows 10上使用TortoiseSVN,并希望在TortoiseSVN中使用英语(默认)拼写检查程序.相反,它使用我既不安装也不想要的德语检查器.这与这个问题完全相反.

在此输入图像描述

请注意,我已将Windows区域设置更改为EN-US,因为TortoiseSVN手册说以下策略适用于TortoiseSVN:

  1. 如果未设置项目语言或未安装该语言,请尝试与Windows语言环境对应的语言.

这是我的Windows语言设置.我甚至指定我的位置在美国(我不是),但它仍然不起作用.

Windows语言设置

有任何想法吗?

svn tortoisesvn localization spell-checking windows-10

5
推荐指数
2
解决办法
942
查看次数

TensorFlow 1.0在Windows上看不到GPU(但Theano确实如此)

我在Windows上运行Keras&Theano的安装(按照本教程).现在我试图将后端切换到Tensorflow,它工作得非常好.

我唯一的问题是,Tensorflow没有检测到我的GPU,而Theano则相反:

from tensorflow.python.client import device_lib
def get_available_gpus():
    local_device_protos = device_lib.list_local_devices()
    return [x.name for x in local_device_protos if x.device_type == 'GPU']
Run Code Online (Sandbox Code Playgroud)

没有结果但是当与Theano后端一起运行时,它运行得非常好:

C:\Programming\Anaconda3\python.exe D:/cnn_classify_cifar10.py 
Using Theano backend.
DEBUG: nvcc STDOUT nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
mod.cu
    Creating library C:/Users/Alex/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-3.5.2-64/tmpgsy496fe/m91973e5c136ea49268a916ff971b7377.lib and object C:/Users/Alex/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-3.5.2-64/tmpgsy496fe/m91973e5c136ea49268a916ff971b7377.exp

Using gpu device 0: GeForce GTX 770 (CNMeM is enabled with initial size: …
Run Code Online (Sandbox Code Playgroud)

python windows gpu keras tensorflow

5
推荐指数
1
解决办法
1213
查看次数

附加属性引发ParseException

我遵循了向XAML中的元素添加自定义属性中的说明但是不幸的是,设计师告诉我他找不到元素,并且在启动程序时收到XamlParserException消息,提示消息无法设置未知成员'{clr-namespace:myNs} MediaElementProperties.MediaId'

我的设置:

  • Xaml-Page用XamlReader.Load(fileStream)显示命令动态加载
  • 内容页面本身使用如下代码:

    <MediaElement myNs:MediaElementProperties.MediaId="test" ... />
    
    Run Code Online (Sandbox Code Playgroud)

    myNs定义为

     xmlns:myNs="clr-namespace:MyNamespace"
    
    Run Code Online (Sandbox Code Playgroud)
  • 以及MediaElementProperties的定义,如下所示:

    namespace MyNamespace {
    public static class MediaElementProperties
    {
        public static readonly DependencyProperty MediaIdProperty = 
           DependencyProperty.Register("MediaId", typeof(string), typeof(MediaElementProperties), new FrameworkPropertyMetadata(string.Empty));
    
        public static string GetMediaId(UIElement element)
        {
            return (string)element.GetValue(MediaIdProperty);
        }
    
        public static void SetMediaId(UIElement element, string value)
        {
            element.SetValue(MediaIdProperty, value);
        }
    }}
    
    Run Code Online (Sandbox Code Playgroud)

您有什么想法为什么我会不断收到例外?

c# wpf xaml attached-properties

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